diff --git a/CMakeLists.txt b/CMakeLists.txt index ddb5c681c..16a17a010 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,6 +258,7 @@ include_directories( ${SCL_BINARY_DIR}/include ) +ADD_SUBDIRECTORY(src/base) ADD_SUBDIRECTORY(src/express) ADD_SUBDIRECTORY(src/exppp) ADD_SUBDIRECTORY(src/fedex_plus) diff --git a/include/scl_export.h b/include/scl_export.h index ab632084a..50ea9a837 100644 --- a/include/scl_export.h +++ b/include/scl_export.h @@ -1,6 +1,19 @@ #ifndef SCL_EXPORT_H #define SCL_EXPORT_H +/* Import/Export flags for base. */ +#ifndef SCL_BASE_EXPORT +# if defined(SCL_BASE_DLL_EXPORTS) && defined(SCL_BASE_DLL_IMPORTS) +# error "Only SCL_BASE_DLL_EXPORTS or SCL_BASE_DLL_IMPORTS can be defined, not both." +# elif defined(SCL_BASE_DLL_EXPORTS) +# define SCL_BASE_EXPORT __declspec(dllexport) +# elif defined(SCL_BASE_DLL_IMPORTS) +# define SCL_BASE_EXPORT __declspec(dllimport) +# else +# define SCL_BASE_EXPORT +# endif +#endif + /* Import/Export flags for express. */ #ifndef SCL_EXPRESS_EXPORT # if defined(SCL_EXPRESS_DLL_EXPORTS) && defined(SCL_EXPRESS_DLL_IMPORTS) diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt new file mode 100644 index 000000000..b88a2be27 --- /dev/null +++ b/src/base/CMakeLists.txt @@ -0,0 +1,20 @@ + +set(SCL_BASE_SOURCES + scl_memmgr.cc +) + +include_directories( + ${SCL_SOURCE_DIR}/include +) + +option(SCL_MEMMGR_ENABLE_CHECKS "Enable scl_memmgr's memory leak detection" OFF) + +if(MSVC OR BORLAND) +add_definitions( -DSCL_BASE_DLL_EXPORTS ) +endif() + +if (${SCL_MEMMGR_ENABLE_CHECKS}) + add_definitions( -DSCL_MEMMGR_ENABLE_CHECKS ) +endif() + +SCL_ADDLIB(base "${SCL_BASE_SOURCES}" "") diff --git a/src/base/scl_memmgr.cc b/src/base/scl_memmgr.cc new file mode 100644 index 000000000..7006ec4db --- /dev/null +++ b/src/base/scl_memmgr.cc @@ -0,0 +1,405 @@ + +#define SCL_MEMMGR_CC +#include "scl_memmgr.h" +#if __APPLE__ +# include +#else +# include +#endif +#include + +#include +#include + +#ifdef SCL_MEMMGR_ENABLE_CHECKS + +/** + scl_memmgr_error definition +*/ +class scl_memmgr_error { + private: + std::string _srcfile; + unsigned int _srcline; + unsigned int _occurences; + public: + scl_memmgr_error( const std::string &file, const unsigned int line ); + scl_memmgr_error( const scl_memmgr_error &rhs ); + ~scl_memmgr_error( void ); + + bool operator<( const scl_memmgr_error &rhs ) const; + + std::string getsrcfile( void ) const; + unsigned int getsrcline( void ) const; + unsigned int getoccurences( void ) const; +}; + +typedef std::set scl_memmgr_errors; +typedef std::set::iterator scl_memmgr_error_iterator; + +/** + scl_memmgr_record definition +*/ +class scl_memmgr_record { + private: + void * _addr; + size_t _size; + std::string _srcfile; + unsigned int _srcline; + public: + scl_memmgr_record( void * addr, size_t size, const char *file, const unsigned int line ); + scl_memmgr_record( void * addr ); + scl_memmgr_record( const scl_memmgr_record &rhs ); + ~scl_memmgr_record( void ); + + bool operator<( const scl_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 scl_memmgr_records; +typedef std::set::iterator scl_memmgr_record_iterator; + +#endif /* SCL_MEMMGR_ENABLE_CHECKS */ + +/** + scl_memmgr definition +*/ +class scl_memmgr { + private: + #ifdef SCL_MEMMGR_ENABLE_CHECKS + bool _record_insert_busy, _record_erase_busy; + // memory allocation/reallocation records, inserted at allocation, erased at deallocation. + scl_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 /* SCL_MEMMGR_ENABLE_CHECKS */ + protected: + public: + scl_memmgr(void); + ~scl_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 ); +}; + +/** + scl_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. +*/ +scl_memmgr memmgr; + +/** + c memory functions implementation +*/ +extern "C" { + + void * scl_malloc_fn( unsigned int size, const char * file, const int line ) { + return memmgr.allocate(size, file, line); + } + + void * scl_calloc_fn( unsigned int count, unsigned int size, const char * file, const int line ) { + return memmgr.allocate(count * size, file, line); + } + + void * scl_realloc_fn( void * addr, unsigned int size, const char * file, const int line ) { + return memmgr.reallocate(addr, size, file, line); + } + + void scl_free_fn( void * addr ) { + memmgr.deallocate(addr, "", 0); + } + +} + +/** + c++ memory operators implementation +*/ +void * scl_operator_new( size_t size, const char * file, const int line ) { + return memmgr.allocate(size, file, line); +} + +void scl_operator_delete( void * addr, const char * file, const int line ) { + memmgr.deallocate(addr, file, line); +} + +void scl_operator_delete( void * addr ) { + memmgr.deallocate(addr, "", 0); +} + +/** + scl_memmgr implementation +*/ +scl_memmgr::scl_memmgr(void) { + #ifdef SCL_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 /* SCL_MEMMGR_ENABLE_CHECKS */ +} + +/** + Destructor: + scl_memmgr::~scl_memmgr(void) + Description: + The scl_memmgr destructor is used to check for memory leaks when enabled. + All records still present when scl_memmgr instance is destroyed can be considered as + memory leaks. +*/ +scl_memmgr::~scl_memmgr(void) { + #ifdef SCL_MEMMGR_ENABLE_CHECKS + scl_memmgr_record_iterator irecord; + scl_memmgr_errors errors; + scl_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 + printf("scl_memmgr warning: Possible memory leaks detected\n"); + } + + // 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 ++) { + scl_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 + printf("scl_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 /* SCL_MEMMGR_ENABLE_CHECKS */ +} + +void * scl_memmgr::allocate( size_t size, const char *file, const int line ) { + void * addr; + + // Allocate + addr = malloc(size); + if (addr == NULL) { + // todo: error allocation failed + printf("scl_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 scl_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 SCL_MEMMGR_ENABLE_CHECKS + if (!_record_insert_busy) + { + // Store record for this allocation + _record_insert_busy = true; + _records.insert(scl_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 /* SCL_MEMMGR_ENABLE_CHECKS */ + + return addr; +} + +void * scl_memmgr::reallocate( void * addr, size_t size, const char *file, const int line ) { + #ifdef SCL_MEMMGR_ENABLE_CHECKS + scl_memmgr_record_iterator record; + + if (!_record_insert_busy) + { + // Find record of previous allocation/reallocation + record = _records.find(scl_memmgr_record(addr)); + if (record == _records.end()) { + // todo: error reallocating memory not allocated? + printf("scl_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 /* SCL_MEMMGR_ENABLE_CHECKS */ + + // Reallocate + addr = realloc(addr, size); + if (addr == NULL) { + // todo: error reallocation failed + printf("scl_memmgr error: Reallocation failed at %s line %d\n", file, line); + } + + #ifdef SCL_MEMMGR_ENABLE_CHECKS + if (!_record_insert_busy) + { + // Store record for this reallocation + _record_insert_busy = true; + _records.insert(scl_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 /* SCL_MEMMGR_ENABLE_CHECKS */ + + return addr; +} + +void scl_memmgr::deallocate( void * addr, const char *file, const int line ) { + #ifdef SCL_MEMMGR_ENABLE_CHECKS + scl_memmgr_record_iterator record; + + if (!_record_erase_busy) + { + // Find record of previous allocation/reallocation + record = _records.find(scl_memmgr_record(addr)); + if (record == _records.end()) { + // todo: error free called for not allocated memory? + printf("scl_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; + } + } + #endif /* SCL_MEMMGR_ENABLE_CHECKS */ + + // Deallocate + free(addr); +} + +#ifdef SCL_MEMMGR_ENABLE_CHECKS +/** + scl_memmgr_error implementation +*/ +scl_memmgr_error::scl_memmgr_error( const std::string &file, const unsigned int line ) { + _srcfile = file; + _srcline = line; + _occurences = 1; +} + +scl_memmgr_error::scl_memmgr_error( const scl_memmgr_error &rhs ) { + _srcfile = rhs._srcfile; + _srcline = rhs._srcline; + _occurences = rhs._occurences; +} + +scl_memmgr_error::~scl_memmgr_error( void ) { +} + +bool scl_memmgr_error::operator<( const scl_memmgr_error &rhs ) const { + if (_srcfile == rhs._srcfile) + return _srcline < rhs._srcline; + return _srcfile < rhs._srcfile; +} + +std::string scl_memmgr_error::getsrcfile( void ) const { + return _srcfile; +} + +unsigned int scl_memmgr_error::getsrcline( void ) const { + return _srcline; +} + +unsigned int scl_memmgr_error::getoccurences( void ) const { + return _occurences; +} + +/** + scl_memmgr_record implementation +*/ +scl_memmgr_record::scl_memmgr_record( void * addr, size_t size, const char *file, const unsigned int line ) { + _addr = addr; + _size = size; + _srcfile = file; + _srcline = line; +} + +scl_memmgr_record::scl_memmgr_record( void * addr ) { + _addr = addr; + _size = 0; + _srcfile = ""; + _srcline = -1; +} + +scl_memmgr_record::scl_memmgr_record( const scl_memmgr_record &rhs ) { + _addr = rhs._addr; + _size = rhs._size; + _srcfile = rhs._srcfile; + _srcline = rhs._srcline; +} + +scl_memmgr_record::~scl_memmgr_record( void ) { +} + +bool scl_memmgr_record::operator<( const scl_memmgr_record &rhs ) const { + return _addr < rhs._addr; +} + +void * scl_memmgr_record::getaddr( void ) const { + return _addr; +} + +size_t scl_memmgr_record::getsize( void ) const { + return _size; +} + +std::string scl_memmgr_record::getsrcfile( void ) const { + return _srcfile; +} + +unsigned int scl_memmgr_record::getsrcline( void ) const { + return _srcline; +} + +#endif /* SCL_MEMMGR_ENABLE_CHECKS */ diff --git a/src/base/scl_memmgr.h b/src/base/scl_memmgr.h new file mode 100644 index 000000000..1f1c47c89 --- /dev/null +++ b/src/base/scl_memmgr.h @@ -0,0 +1,80 @@ +#ifndef SCL_MEMMGR_H +#define SCL_MEMMGR_H + +#include + +/** + 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" { +#endif /* __cplusplus */ + +SCL_BASE_EXPORT void * scl_malloc_fn( unsigned int size, const char *file, const int line ); +SCL_BASE_EXPORT void * scl_calloc_fn( unsigned int count, unsigned int size, const char *file, const int line ); +SCL_BASE_EXPORT void * scl_realloc_fn( void * addr, unsigned int size, const char *file, const int line ); +SCL_BASE_EXPORT void scl_free_fn( void * addr ); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#ifdef __cplusplus + +SCL_BASE_EXPORT void * scl_operator_new( size_t size, const char * file, const int line ); +SCL_BASE_EXPORT void scl_operator_delete( void * addr, const char *file, const int line ); +SCL_BASE_EXPORT void scl_operator_delete( void * addr ); + +#endif /* __cplusplus */ + +#ifndef SCL_MEMMGR_CC + +#define scl_malloc(size) scl_malloc_fn(size, __FILE__, __LINE__) +#define scl_calloc(count, size) scl_calloc_fn(count, size, __FILE__, __LINE__) +#define scl_realloc(addr, size) scl_realloc_fn(addr, size, __FILE__, __LINE__) +#define scl_free(addr) scl_free_fn(addr) + +#ifdef __cplusplus + +#include + +inline void * operator new( size_t size, const char *file, const int line ) THROW_STD_BAD_ALLOC { + return scl_operator_new(size, file, line); +} + +inline void * operator new[]( size_t size, const char *file, const int line ) THROW_STD_BAD_ALLOC { + return scl_operator_new(size, file, line); +} + +inline void operator delete( void *addr, const char *file, const int line ) THROW_STD_BAD_ALLOC { + scl_operator_delete(addr, file, line); +} + +inline void operator delete[]( void *addr, const char *file, const int line ) THROW_STD_BAD_ALLOC { + scl_operator_delete(addr, file, line); +} + +inline void operator delete( void * addr ) THROW_EMPTY { + scl_operator_delete(addr); +} + +inline void operator delete[]( void * addr ) THROW_EMPTY { + scl_operator_delete(addr); +} + +#define new new(__FILE__, __LINE__) + +#endif /* __cplusplus */ + +#endif /* SCL_MEMMGR_CC */ + +#endif /* SCL_MEMMGR_H */ diff --git a/src/exppp/CMakeLists.txt b/src/exppp/CMakeLists.txt index 15db3f7fb..1935af282 100644 --- a/src/exppp/CMakeLists.txt +++ b/src/exppp/CMakeLists.txt @@ -10,18 +10,20 @@ set(LIBEXPPP_SOURCES include_directories( ${SCL_SOURCE_DIR}/include ${SCL_SOURCE_DIR}/include/exppp + ${SCL_SOURCE_DIR}/src/base ) if(MSVC OR BORLAND) add_definitions( -DSCL_EXPPP_DLL_EXPORTS ) add_definitions( -DSCL_EXPRESS_DLL_IMPORTS ) +add_definitions( -DSCL_BASE_DLL_IMPORTS ) endif() if(BORLAND) add_definitions( -D__STDC__ ) endif() -SCL_ADDLIB(libexppp "${LIBEXPPP_SOURCES}" express) +SCL_ADDLIB(libexppp "${LIBEXPPP_SOURCES}" "express base") set_target_properties(libexppp PROPERTIES PREFIX "") #SCL_ADDEXEC(exppp "${EXPPP_SOURCES}" "libexppp express") diff --git a/src/exppp/exppp.c b/src/exppp/exppp.c index 50e9ef952..1e8593426 100644 --- a/src/exppp/exppp.c +++ b/src/exppp/exppp.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -1501,7 +1502,7 @@ TYPE_body_out( Type t, int level ) { while( 0 != ( expr = ( Expression )DICTdo( &de ) ) ) { count++; } - names = ( char ** )malloc( count * sizeof( char * ) ); + names = ( char ** )scl_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; @@ -1525,7 +1526,7 @@ TYPE_body_out( Type t, int level ) { raw( names[i] ); } raw( ")" ); - free( ( char * )names ); + scl_free( ( char * )names ); } #else wrap( " ENUMERATION OF\n" ); @@ -2025,7 +2026,7 @@ prep_string() { } string_func_in_use = true; - exppp_buf = exppp_bufp = ( char * )malloc( BIGBUFSIZ ); + exppp_buf = exppp_bufp = ( char * )scl_malloc( BIGBUFSIZ ); if( !exppp_buf ) { fprintf( stderr, "failed to allocate exppp buffer\n" ); return false; @@ -2044,7 +2045,7 @@ prep_string() { static char * finish_string() { - char * b = ( char * )realloc( exppp_buf, 1 + exppp_maxbuflen - exppp_buflen ); + char * b = ( char * )scl_realloc( exppp_buf, 1 + exppp_maxbuflen - exppp_buflen ); if( b == 0 ) { fprintf( stderr, "failed to reallocate exppp buffer\n" ); diff --git a/src/express/CMakeLists.txt b/src/express/CMakeLists.txt index 3a23a9f03..529e44119 100644 --- a/src/express/CMakeLists.txt +++ b/src/express/CMakeLists.txt @@ -70,6 +70,7 @@ SET(EXPRESS_PRIVATE_HDRS include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + ${SCL_SOURCE_DIR}/src/base ) add_definitions( -DFLEX ) @@ -80,9 +81,10 @@ endif() if(BORLAND) add_definitions( -D__STDC__ ) +add_definitions( -DSCL_BASE_DLL_IMPORTS ) endif() -SCL_ADDLIB(express "${EXPRESS_SOURCES}" "") +SCL_ADDLIB(express "${EXPRESS_SOURCES}" "base") if(APPLE) set_target_properties(express PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress") diff --git a/src/express/alg.c b/src/express/alg.c index 2cc0910a5..79581f444 100644 --- a/src/express/alg.c +++ b/src/express/alg.c @@ -38,6 +38,7 @@ * prettied up interface to print_objects_when_running */ +#include #define ALGORITHM_C #include "express/alg.h" #include "express/object.h" diff --git a/src/express/caseitem.c b/src/express/caseitem.c index 57312f19d..8d3f8fd6e 100644 --- a/src/express/caseitem.c +++ b/src/express/caseitem.c @@ -29,6 +29,7 @@ * prettied up interface to print_objects_when_running */ +#include #define CASE_ITEM_C #include "express/caseitem.h" diff --git a/src/express/dict.c b/src/express/dict.c index 0b7fe3f70..29bf1d575 100644 --- a/src/express/dict.c +++ b/src/express/dict.c @@ -33,6 +33,7 @@ * Initial revision */ +#include #define DICTIONARY_C #include "express/dict.h" #include "express/object.h" diff --git a/src/express/entity.c b/src/express/entity.c index 89a340bcd..a0f5fd990 100644 --- a/src/express/entity.c +++ b/src/express/entity.c @@ -111,6 +111,7 @@ * */ +#include #define ENTITY_C #include "express/entity.h" #include "express/express.h" diff --git a/src/express/error.c b/src/express/error.c index 79f04cf96..13ea8f771 100644 --- a/src/express/error.c +++ b/src/express/error.c @@ -52,6 +52,7 @@ */ #include +#include #include #include #ifdef HAVE_UNISTD_H @@ -105,7 +106,7 @@ void ERRORinitialize( void ) { ERROR_syntax_expecting = ERRORcreate( "%s, expecting %s in %s %s", SEVERITY_EXIT ); - ERROR_string_base = ( char * )malloc( ERROR_MAX_SPACE ); + ERROR_string_base = ( char * )scl_malloc( ERROR_MAX_SPACE ); ERROR_start_message_buffer(); @@ -410,7 +411,7 @@ void ERRORnospace() { Error ERRORcreate( char * message, Severity severity ) { Error n; - n = ( struct Error_ * )malloc( sizeof( struct Error_ ) ); + n = ( struct Error_ * )scl_malloc( sizeof( struct Error_ ) ); n->message = message; n->severity = severity; n->enabled = true; diff --git a/src/express/expr.c b/src/express/expr.c index 538aacb2b..b78cb132c 100644 --- a/src/express/expr.c +++ b/src/express/expr.c @@ -71,6 +71,7 @@ */ #include +#include #define EXPRESSION_C #ifdef HAVE_UNISTD_H diff --git a/src/express/express.c b/src/express/express.c index f85b0f997..c4745bba6 100644 --- a/src/express/express.c +++ b/src/express/express.c @@ -69,6 +69,7 @@ */ #include +#include #define EXPRESS_C #include "express/basic.h" #include @@ -138,7 +139,7 @@ Symbol * EXPRESS_get_symbol( Generic e ) { Express EXPRESScreate() { Express model = SCOPEcreate( OBJ_EXPRESS ); - model->u.express = ( struct Express_ * )calloc( 1, sizeof( struct Express_ ) ); + model->u.express = ( struct Express_ * )scl_calloc( 1, sizeof( struct Express_ ) ); return model; } @@ -157,7 +158,7 @@ static void EXPRESS_PATHinit() { p = getenv( "EXPRESS_PATH" ); if( !p ) { /* if no EXPRESS_PATH, search current directory anyway */ - dir = ( Dir * )malloc( sizeof( Dir ) ); + dir = ( Dir * )scl_malloc( sizeof( Dir ) ); dir->leaf = dir->full; LISTadd( EXPRESS_path, ( Generic )dir ); } else { @@ -189,7 +190,7 @@ static void EXPRESS_PATHinit() { } p++; /* leave p after terminating null */ - dir = ( Dir * )malloc( sizeof( Dir ) ); + dir = ( Dir * )scl_malloc( sizeof( Dir ) ); /* if it's just ".", make it as if it was */ /* just "" to make error messages cleaner */ @@ -388,7 +389,7 @@ void EXPRESSparse( Express model, FILE * fp, char * filename ) { length -= 4; } - model->u.express->basename = ( char * )malloc( length + 1 ); + model->u.express->basename = ( char * )scl_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 e264a57ba..b2d97e20b 100644 --- a/src/express/fedex.c +++ b/src/express/fedex.c @@ -72,6 +72,7 @@ */ #include +#include #include #include "scl_version_string.h" #include diff --git a/src/express/hash.c b/src/express/hash.c index a23162222..5639d1e60 100644 --- a/src/express/hash.c +++ b/src/express/hash.c @@ -105,6 +105,7 @@ * */ +#include #define HASH_C #include #include @@ -297,7 +298,7 @@ HASHdestroy( Hash_Table table ) { p = q; } } - free( table->Directory[i] ); + scl_free( table->Directory[i] ); } } HASH_Table_destroy( table ); @@ -315,11 +316,11 @@ void * HASHfind( Hash_Table t, char * s ) { // Element * ep; struct Element_ *ep = NULL; - struct Element_ *e = malloc( sizeof * e ); + struct Element_ *e = scl_malloc( sizeof * e ); e -> key = s; e -> symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */ ep = HASHsearch( t, e, HASH_FIND ); - free(e); + scl_free(e); return( ep ? ep->data : 0 ); } @@ -329,7 +330,7 @@ void HASHinsert( Hash_Table t, char * s, void * data ) { Element e2; // memset(e, 0, sizeof(s) + sizeof(data)); - struct Element_ *e = malloc( sizeof * e ); + struct Element_ *e = scl_malloc( sizeof * e ); e -> key = s; e -> data = data; e -> symbol = 0; /* initialize to 0 - 25-Apr-1994 - kcm */ diff --git a/src/express/lexact.c b/src/express/lexact.c index b2d96f535..53374cc1a 100644 --- a/src/express/lexact.c +++ b/src/express/lexact.c @@ -51,6 +51,7 @@ * prettied up interface to print_objects_when_running */ +#include #define LEX_ACTIONS_C #include #include @@ -308,7 +309,7 @@ SCANprocess_logical_literal( char * string ) { break; /* default will actually be triggered by 'UNKNOWN' keyword */ } - free( string ); + scl_free( string ); return TOK_LOGICAL_LITERAL; } @@ -322,7 +323,7 @@ SCANprocess_identifier_or_keyword( void ) { /* make uppercase copy */ len = strlen( yytext ); - dest = test_string = ( char * )malloc( len + 1 ); + dest = test_string = ( char * )scl_malloc( len + 1 ); for( src = yytext; *src; src++, dest++ ) { *dest = ( islower( *src ) ? toupper( *src ) : *src ); } @@ -338,7 +339,7 @@ SCANprocess_identifier_or_keyword( void ) { case TOK_LOGICAL_LITERAL: return SCANprocess_logical_literal( test_string ); default: - free( test_string ); + scl_free( test_string ); return k->token; } } @@ -534,7 +535,7 @@ SCANupperize( char * s ) { char * SCANstrdup( char * s ) { - char * s2 = ( char * )malloc( strlen( s ) + 1 ); + char * s2 = ( char * )scl_malloc( strlen( s ) + 1 ); if( !s2 ) { return 0; } diff --git a/src/express/linklist.c b/src/express/linklist.c index 08ce7e376..a5a2f7b19 100644 --- a/src/express/linklist.c +++ b/src/express/linklist.c @@ -21,6 +21,7 @@ * prettied up interface to print_objects_when_running */ +#include #define LINKED_LIST_C #include "express/linklist.h" diff --git a/src/express/memory.c b/src/express/memory.c index 5fbe13b79..e56c11a9f 100644 --- a/src/express/memory.c +++ b/src/express/memory.c @@ -34,6 +34,7 @@ Now you can say things like: foo_destroy(foo1); */ +#include #include #include #include "express/memory.h" diff --git a/src/express/object.c b/src/express/object.c index 0908952fe..80ce932e6 100644 --- a/src/express/object.c +++ b/src/express/object.c @@ -21,6 +21,7 @@ * prettied up interface to print_objects_when_running */ +#include #define OBJECT_C #include #include "express/object.h" @@ -35,7 +36,7 @@ Symbol * UNK_get_symbol( Generic x ) { void OBJinitialize() { int i; - OBJ = ( struct Object * )malloc( MAX_OBJECT_TYPES * sizeof( struct Object ) ); + OBJ = ( struct Object * )scl_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"; diff --git a/src/express/resolve.c b/src/express/resolve.c index 5eda0bf61..da03ba1b4 100644 --- a/src/express/resolve.c +++ b/src/express/resolve.c @@ -56,6 +56,7 @@ */ #include +#include #define RESOLVE_C #include #ifdef HAVE_UNISTD_H diff --git a/src/express/schema.c b/src/express/schema.c index 2ae8b5629..a2cb13f65 100644 --- a/src/express/schema.c +++ b/src/express/schema.c @@ -46,6 +46,7 @@ */ #include +#include #define SCHEMA_C #ifdef HAVE_UNISTD_H # include diff --git a/src/express/scope.c b/src/express/scope.c index aeb2d6860..f766d14d3 100644 --- a/src/express/scope.c +++ b/src/express/scope.c @@ -38,6 +38,7 @@ * 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 76bebb85f..97b4b441d 100644 --- a/src/express/stmt.c +++ b/src/express/stmt.c @@ -40,6 +40,7 @@ * */ +#include #define STATEMENT_C #include "express/stmt.h" diff --git a/src/express/symbol.c b/src/express/symbol.c index b58616807..767da4027 100644 --- a/src/express/symbol.c +++ b/src/express/symbol.c @@ -32,6 +32,7 @@ * Initial revision */ +#include #define SYMBOL_C #include "express/symbol.h" diff --git a/src/express/type.c b/src/express/type.c index e65a78c70..229d04482 100644 --- a/src/express/type.c +++ b/src/express/type.c @@ -122,6 +122,7 @@ This module implements the type abstraction. It is * */ +#include #define TYPE_C #include "express/type.h" diff --git a/src/express/variable.c b/src/express/variable.c index f44649fc1..d96130a4e 100644 --- a/src/express/variable.c +++ b/src/express/variable.c @@ -83,6 +83,7 @@ * */ +#include #define VARIABLE_C #include #include "express/variable.h" diff --git a/src/fedex_plus/CMakeLists.txt b/src/fedex_plus/CMakeLists.txt index e4240eb69..f9e1f161f 100644 --- a/src/fedex_plus/CMakeLists.txt +++ b/src/fedex_plus/CMakeLists.txt @@ -25,6 +25,7 @@ include_directories( ${SCL_SOURCE_DIR}/include ${SCL_SOURCE_DIR}/include/exppp ${SCL_SOURCE_DIR}/include/express + ${SCL_SOURCE_DIR}/src/base ) IF(MSVC OR BORLAND) @@ -33,12 +34,13 @@ set(fedex_plus_EXTRA_SOURCES ) add_definitions( -DSCL_EXPRESS_DLL_IMPORTS ) add_definitions( -DSCL_EXPPP_DLL_IMPORTS ) +add_definitions( -DSCL_BASE_DLL_IMPORTS ) ENDIF() IF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug") add_definitions( -DYYDEBUG ) #-Ddebugging ) ENDIF() -SCL_ADDEXEC(fedex_plus "${fedex_plus_SOURCES} ${fedex_plus_EXTRA_SOURCES}" "libexppp express") +SCL_ADDEXEC(fedex_plus "${fedex_plus_SOURCES} ${fedex_plus_EXTRA_SOURCES}" "libexppp express base") add_dependencies( fedex_plus version_string ) \ No newline at end of file diff --git a/src/fedex_plus/classes.c b/src/fedex_plus/classes.c index 1b08ad711..d29b59833 100644 --- a/src/fedex_plus/classes.c +++ b/src/fedex_plus/classes.c @@ -25,6 +25,7 @@ N350 ( August 31, 1993 ) of ISO 10303 TC184/SC4/WG7. /* this is used to add new dictionary calls */ /* #define NEWDICT */ +#include #include #include "classes.h" @@ -446,7 +447,7 @@ char * generate_attribute_name( Variable a, char * out ) { p++; } *q = '\0'; - free( temp ); + scl_free( temp ); return out; } @@ -503,7 +504,7 @@ char * generate_dict_attr_name( Variable a, char * out ) { } } - free( temp ); + scl_free( temp ); return out; } @@ -595,7 +596,7 @@ char * TYPEget_express_type( const Type t ) { /* this will declare extra memory when aggregate is > 1D */ - permval = ( char * )malloc( strlen( retval ) * sizeof( char ) + 1 ); + permval = ( char * )scl_malloc( strlen( retval ) * sizeof( char ) + 1 ); strcpy( permval, retval ); return permval; @@ -2018,7 +2019,7 @@ void ENTITYincode_print( Entity entity, FILE * file, Schema schema ) { format_for_std_stringout( file, tmp ); fprintf( file, "\n str.append( \")\" );\n" ); fprintf( file, " %s::%s%s->AddSupertype_Stmt( str );", schema_name, ENT_PREFIX, entity_name ); - free( tmp ); + scl_free( tmp ); } else { fprintf( file, " %s::%s%s->AddSupertype_Stmt( \"ABSTRACT SUPERTYPE\" );\n", schema_name, ENT_PREFIX, entity_name ); @@ -2029,7 +2030,7 @@ void ENTITYincode_print( Entity entity, FILE * file, Schema schema ) { tmp = SUBTYPEto_string( entity->u.entity->subtype_expression ); format_for_std_stringout( file, tmp ); fprintf( file, "\n str.append( \")\" );\n" ); - free( tmp ); + scl_free( tmp ); fprintf( file, " %s::%s%s->AddSupertype_Stmt( str );", schema_name, ENT_PREFIX, entity_name ); } } @@ -2181,15 +2182,15 @@ void ENTITYincode_print( Entity entity, FILE * file, Schema schema ) { if( VARis_derived( v ) && v->initializer ) { tmp = EXPRto_string( v->initializer ); - tmp2 = ( char * )malloc( sizeof( char ) * ( strlen( tmp ) + BUFSIZ ) ); + tmp2 = ( char * )scl_malloc( sizeof( char ) * ( strlen( tmp ) + BUFSIZ ) ); fprintf( file, " %s::%s%d%s%s->initializer_(\"%s\");\n", schema_name, ATTR_PREFIX, attr_count, ( VARis_derived( v ) ? "D" : ( VARis_type_shifter( v ) ? "R" : ( VARget_inverse( v ) ? "I" : "" ) ) ), attrnm, format_for_stringout( tmp, tmp2 ) ); - free( tmp ); - free( tmp2 ); + scl_free( tmp ); + scl_free( tmp2 ); } if( VARget_inverse( v ) ) { fprintf( file, " %s::%s%d%s%s->inverted_attr_id_(\"%s\");\n", @@ -2403,11 +2404,11 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap if( whereRule_formatted_size == 0 ) { whereRule_formatted_size = 3 * BUFSIZ; - whereRule_formatted = ( char * )malloc( sizeof( char ) * whereRule_formatted_size ); + whereRule_formatted = ( char * )scl_malloc( sizeof( char ) * whereRule_formatted_size ); } else if( ( strlen( whereRule ) + 300 ) > whereRule_formatted_size ) { - free( whereRule_formatted ); + scl_free( whereRule_formatted ); whereRule_formatted_size = strlen( whereRule ) + BUFSIZ; - whereRule_formatted = ( char * )malloc( sizeof( char ) * whereRule_formatted_size ); + whereRule_formatted = ( char * )scl_malloc( sizeof( char ) * whereRule_formatted_size ); } whereRule_formatted[0] = '\0'; if( w->label ) { @@ -2481,7 +2482,7 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap fprintf( files->create, " %s::%s%s->_where_rules->Append(wr);\n", SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); - free( whereRule ); + scl_free( whereRule ); ptr2 = whereRule = 0; LISTod } @@ -2494,7 +2495,7 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap SCHEMAget_name( schema ), ENT_PREFIX, ENTITYget_name( entity ) ); if( whereRule_formatted_size == 0 ) { - uniqRule_formatted = ( char * )malloc( sizeof( char ) * 2 * BUFSIZ ); + uniqRule_formatted = ( char * )scl_malloc( sizeof( char ) * 2 * BUFSIZ ); whereRule_formatted = uniqRule_formatted; } else { uniqRule_formatted = whereRule_formatted; @@ -2534,7 +2535,7 @@ void ENTITYprint_new( Entity entity, FILES * files, Schema schema, int externMap } if( whereRule_formatted_size > 0 ) { - free( whereRule_formatted ); + scl_free( whereRule_formatted ); } n = ENTITYget_classname( entity ); @@ -2775,7 +2776,7 @@ void Type_Description( const Type, char * ); * return it in static buffer */ char * TypeDescription( const Type t ) { - static char buf[4000]; + static char buf[5000]; buf[0] = '\0'; @@ -3467,11 +3468,11 @@ void TYPEprint_new( const Type type, FILE * create, Schema schema ) { if( whereRule_formatted_size == 0 ) { whereRule_formatted_size = 3 * BUFSIZ; - whereRule_formatted = ( char * )malloc( sizeof( char ) * whereRule_formatted_size ); + whereRule_formatted = ( char * )scl_malloc( sizeof( char ) * whereRule_formatted_size ); } else if( ( strlen( whereRule ) + 300 ) > whereRule_formatted_size ) { - free( whereRule_formatted ); + scl_free( whereRule_formatted ); whereRule_formatted_size = strlen( whereRule ) + BUFSIZ; - whereRule_formatted = ( char * )malloc( sizeof( char ) * whereRule_formatted_size ); + whereRule_formatted = ( char * )scl_malloc( sizeof( char ) * whereRule_formatted_size ); } whereRule_formatted[0] = '\0'; if( w->label ) { @@ -3529,10 +3530,10 @@ void TYPEprint_new( const Type type, FILE * create, Schema schema ) { fprintf( create, " %s->_where_rules->Append(wr);\n", TYPEtd_name( type ) ); - free( whereRule ); + scl_free( whereRule ); ptr2 = whereRule = 0; LISTod - free( whereRule_formatted ); + scl_free( whereRule_formatted ); } } diff --git a/src/fedex_plus/classes_misc.c b/src/fedex_plus/classes_misc.c index 7d7e9b56a..df5bea111 100644 --- a/src/fedex_plus/classes_misc.c +++ b/src/fedex_plus/classes_misc.c @@ -1,4 +1,5 @@ #define CLASSES_MISC_C +#include #include #include "classes.h" /******************************************************************* @@ -674,7 +675,7 @@ ENTITYput_superclass( Entity entity ) { LISTod; } - tag = ( EntityTag ) malloc( sizeof( struct EntityTag_ ) ); + tag = ( EntityTag ) scl_malloc( sizeof( struct EntityTag_ ) ); tag -> superclass = super; TYPEput_clientData( ENTITYget_type( entity ), ( ClientData ) tag ); return super; @@ -742,10 +743,10 @@ VARis_type_shifter( Variable a ) { temp = EXPRto_string( VARget_name( a ) ); if( ! strncmp( StrToLower( temp ), "self\\", 5 ) ) { /* a is a type shifter */ - free( temp ); + scl_free( temp ); return a; } - free( temp ); + scl_free( temp ); return 0; } diff --git a/src/fedex_plus/classes_wrapper.cc b/src/fedex_plus/classes_wrapper.cc index 50be9a23d..740c6163d 100644 --- a/src/fedex_plus/classes_wrapper.cc +++ b/src/fedex_plus/classes_wrapper.cc @@ -3,6 +3,7 @@ #include #include "complexSupport.h" +#include /******************************************************************* ** FedEx parser output module for generating C++ class definitions diff --git a/src/fedex_plus/collect.cc b/src/fedex_plus/collect.cc index cfe9d0ce4..c9f5aca49 100644 --- a/src/fedex_plus/collect.cc +++ b/src/fedex_plus/collect.cc @@ -12,6 +12,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include void ComplexCollect::insert( ComplexList * c ) /* diff --git a/src/fedex_plus/complexlist.cc b/src/fedex_plus/complexlist.cc index 3ec03874e..b811fcff5 100644 --- a/src/fedex_plus/complexlist.cc +++ b/src/fedex_plus/complexlist.cc @@ -11,6 +11,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include ComplexList::~ComplexList() /* diff --git a/src/fedex_plus/entlist.cc b/src/fedex_plus/entlist.cc index bd45be671..9c917bd18 100644 --- a/src/fedex_plus/entlist.cc +++ b/src/fedex_plus/entlist.cc @@ -14,6 +14,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include int EntList::siblings() /* diff --git a/src/fedex_plus/entnode.cc b/src/fedex_plus/entnode.cc index 621c13469..d288e07be 100644 --- a/src/fedex_plus/entnode.cc +++ b/src/fedex_plus/entnode.cc @@ -12,6 +12,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include EntNode::EntNode( char * namelist[] ) /* diff --git a/src/fedex_plus/expressbuild.cc b/src/fedex_plus/expressbuild.cc index 01cd0fc7e..b8652318d 100644 --- a/src/fedex_plus/expressbuild.cc +++ b/src/fedex_plus/expressbuild.cc @@ -12,6 +12,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include // Local function prototypes: static void initEnts( Express ); diff --git a/src/fedex_plus/fedex_main.c b/src/fedex_plus/fedex_main.c index 1bbdd1335..edc457a27 100644 --- a/src/fedex_plus/fedex_main.c +++ b/src/fedex_plus/fedex_main.c @@ -72,6 +72,7 @@ * Added * to typedefs. Replaced warning kludges with ERRORoption. */ +#include #include #include #include "../express/express.h" diff --git a/src/fedex_plus/match-ors.cc b/src/fedex_plus/match-ors.cc index 2c4bf3e92..c22daadc9 100644 --- a/src/fedex_plus/match-ors.cc +++ b/src/fedex_plus/match-ors.cc @@ -14,6 +14,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include MatchType AndOrList::matchORs( EntNode * ents ) /* diff --git a/src/fedex_plus/multlist.cc b/src/fedex_plus/multlist.cc index 36d852f6a..2f5f278a3 100644 --- a/src/fedex_plus/multlist.cc +++ b/src/fedex_plus/multlist.cc @@ -13,6 +13,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include MultList::~MultList() /* diff --git a/src/fedex_plus/multpass.c b/src/fedex_plus/multpass.c index 4409e62c0..ebb223dcd 100644 --- a/src/fedex_plus/multpass.c +++ b/src/fedex_plus/multpass.c @@ -31,6 +31,7 @@ * Date: 04/09/97 * *****************************************************************************/ +#include #include #include "classes.h" @@ -184,7 +185,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 * )malloc( sizeof( int ) ); + schema->clientData = ( int * )scl_malloc( sizeof( int ) ); *( int * )schema->clientData = 0; SCOPEdo_entities( schema, ent, de_ent ) ent->search_id = NOTKNOWN; diff --git a/src/fedex_plus/non-ors.cc b/src/fedex_plus/non-ors.cc index 6b05bb378..615537786 100644 --- a/src/fedex_plus/non-ors.cc +++ b/src/fedex_plus/non-ors.cc @@ -11,6 +11,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include MatchType SimpleList::matchNonORs( EntNode * ents ) /* diff --git a/src/fedex_plus/orlist.cc b/src/fedex_plus/orlist.cc index 809804320..85ff29ebd 100644 --- a/src/fedex_plus/orlist.cc +++ b/src/fedex_plus/orlist.cc @@ -11,6 +11,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include int OrList::hit( const char * nm ) /* diff --git a/src/fedex_plus/print.cc b/src/fedex_plus/print.cc index b338c5954..4a4ad0855 100644 --- a/src/fedex_plus/print.cc +++ b/src/fedex_plus/print.cc @@ -8,6 +8,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include // Local function prototypes: static char * joinText( JoinType, char * ); diff --git a/src/fedex_plus/selects.c b/src/fedex_plus/selects.c index 3662c2e59..9855d9e29 100644 --- a/src/fedex_plus/selects.c +++ b/src/fedex_plus/selects.c @@ -22,6 +22,7 @@ extern int multiple_inheritance; ******** The functions in this file generate C++ code for representing ******** EXPRESS SELECT types. **************************************************************************/ +#include #include #include "classes.h" @@ -464,7 +465,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 * )scl_malloc( BUFSIZ ); typestr[0] = '\0'; strcat( typestr, ( char * )"(" ); for( i = 0; i <= tnumber; i++ ) { @@ -1946,7 +1947,7 @@ TYPEselect_print( Type t, FILES * files, Schema schema ) { } /* mark the type as being processed */ - tag = ( SelectTag ) malloc( sizeof( struct SelectTag_ ) ); + tag = ( SelectTag ) scl_malloc( sizeof( struct SelectTag_ ) ); tag -> started = 1; tag -> complete = 0; TYPEput_clientData( t, ( ClientData ) tag ); diff --git a/src/fedex_plus/trynext.cc b/src/fedex_plus/trynext.cc index 5ed932aec..d77f8c4da 100644 --- a/src/fedex_plus/trynext.cc +++ b/src/fedex_plus/trynext.cc @@ -12,6 +12,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include // Local function prototypes: static EntList * firstCandidate( EntList * ); diff --git a/src/fedex_plus/write.cc b/src/fedex_plus/write.cc index dd7f373de..508376055 100644 --- a/src/fedex_plus/write.cc +++ b/src/fedex_plus/write.cc @@ -11,6 +11,7 @@ *****************************************************************************/ #include "complexSupport.h" +#include // Local function prototypes: static void writeheader( ostream &, int ); diff --git a/src/fedex_python/CMakeLists.txt b/src/fedex_python/CMakeLists.txt index a434ad25a..8d867190a 100644 --- a/src/fedex_python/CMakeLists.txt +++ b/src/fedex_python/CMakeLists.txt @@ -4,6 +4,7 @@ include_directories( ${SCL_SOURCE_DIR}/include ${SCL_SOURCE_DIR}/include/exppp ${SCL_SOURCE_DIR}/include/express + ${SCL_SOURCE_DIR}/src/base ${SCL_SOURCE_DIR}/src/fedex_plus ) @@ -13,6 +14,7 @@ IF(MSVC) set(fedex_plus_MSVC_SOURCES ${SCL_SOURCE_DIR}/src/fedex_plus/xgetopt.cc ) +add_definitions( -DSCL_BASE_DLL_IMPORTS ) add_definitions( -DSCL_EXPRESS_DLL_IMPORTS ) add_definitions( -DSCL_EXPPP_DLL_IMPORTS ) ENDIF(MSVC) @@ -38,7 +40,7 @@ set(fedex_python_SOURCES ${SCL_SOURCE_DIR}/src/fedex_plus/write.cc ${SCL_SOURCE_DIR}/src/fedex_plus/print.cc ) -SCL_ADDEXEC(fedex_python "${fedex_python_SOURCES} ${fedex_plus_MSVC_SOURCES}" "libexppp express") +SCL_ADDEXEC(fedex_python "${fedex_python_SOURCES} ${fedex_plus_MSVC_SOURCES}" "libexppp express base") add_dependencies( fedex_python version_string ) endif(PYTHON_GENERATOR) diff --git a/src/fedex_python/src/classes_python.c b/src/fedex_python/src/classes_python.c index 7419e962c..05712438e 100644 --- a/src/fedex_python/src/classes_python.c +++ b/src/fedex_python/src/classes_python.c @@ -533,6 +533,7 @@ process_aggregate (FILE *file, Type t) { char *lower_str = EXPRto_string(lower); Expression upper = AGGR_TYPEget_upper_limit(t); char *upper_str = NULL; + Type base_type; if (upper == LITERAL_INFINITY) { upper_str = "None"; } @@ -557,7 +558,7 @@ process_aggregate (FILE *file, Type t) { } fprintf(file,"(%s,%s,",lower_str,upper_str); //write base type - Type base_type = TYPEget_base_type(t); + base_type = TYPEget_base_type(t); if (TYPEis_aggregate(base_type)) { process_aggregate(file,base_type); fprintf(file,")"); //close parenthesis @@ -567,7 +568,6 @@ process_aggregate (FILE *file, Type t) { //fprintf(file,"%s)",array_base_type); fprintf(file,"'%s')",array_base_type); } - } void @@ -578,6 +578,11 @@ LIBdescribe_entity( Entity entity, FILE * file, Schema schema ) { bool generate_constructor = true; //by default, generates a python constructor bool inheritance = false; Type t; + Linked_List list; + int num_parent = 0; + int num_derived_inverse_attr = 0; + int index_attribute = 0; + /* class name need to use new-style classes for properties to work correctly so class must inherit from object */ @@ -587,9 +592,8 @@ LIBdescribe_entity( Entity entity, FILE * file, Schema schema ) { /* * Look for inheritance and super classes */ - Linked_List list; list = ENTITYget_supertypes( entity ); - int num_parent = 0; + num_parent = 0; if( ! LISTempty( list ) ) { inheritance = true; LISTdo( list, e, Entity ) @@ -632,7 +636,7 @@ LIBdescribe_entity( Entity entity, FILE * file, Schema schema ) { * other wise just a 'pass' statement is enough */ attr_count_tmp = 0; - int num_derived_inverse_attr = 0; + num_derived_inverse_attr = 0; LISTdo(ENTITYget_attributes( entity ), v, Variable) if (VARis_derived(v) || VARget_inverse(v)) { num_derived_inverse_attr++; @@ -656,7 +660,8 @@ LIBdescribe_entity( Entity entity, FILE * file, Schema schema ) { } // if inheritance, first write the inherited parameters list = ENTITYget_supertypes( entity ); - int num_parent = 0, index_attribute = 0; + num_parent = 0; + index_attribute = 0; if( ! LISTempty( list ) ) { LISTdo( list, e, Entity ) /* search attribute names for superclass */ diff --git a/src/fedex_python/src/selects_python.c b/src/fedex_python/src/selects_python.c index 4b901c1ec..6e9c7b292 100644 --- a/src/fedex_python/src/selects_python.c +++ b/src/fedex_python/src/selects_python.c @@ -690,6 +690,9 @@ class. *******************/ void TYPEselect_lib_print( const Type type, FILE * f, Schema schema ) { + int nbr_select = 0; + int num = 0; + fprintf( f, "# SELECT TYPE %s_\n", TYPEget_name(type) ); // writes the variable with strings LISTdo( SEL_TYPEget_items( type ), t, Type ) @@ -712,12 +715,12 @@ TYPEselect_lib_print( const Type type, FILE * f, Schema schema ) { } // first compute the number of types (necessary to insert commas) - int nbr_select = 0; + nbr_select = 0; LISTdo( SEL_TYPEget_items( type ), t, Type ) nbr_select++; LISTod; // then write types - int num = 0; + num = 0; LISTdo( SEL_TYPEget_items( type ), t, Type ) if (is_python_keyword(TYPEget_name(t))) { fprintf( f, "\n\t'%s_'",TYPEget_name(t));