Compare commits
76
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
131fe6e7b4 | ||
|
|
627c0935a8 | ||
|
|
c2842f884a | ||
|
|
80b4588f6a | ||
|
|
e05bfc7bd4 | ||
|
|
f83e0abc74 | ||
|
|
0978cfcd00 | ||
|
|
28783de62b | ||
|
|
7dbda20be0 | ||
|
|
fdf271c888 | ||
|
|
8e9a68968c | ||
|
|
520e7a3789 | ||
|
|
4bab26918d | ||
|
|
efd353858e | ||
|
|
9b15e1c697 | ||
|
|
64873b4dd7 | ||
|
|
28c5d26429 | ||
|
|
43231cdbc9 | ||
|
|
7209a3e75d | ||
|
|
88e512c92c | ||
|
|
09deafbe23 | ||
|
|
830e29fb80 | ||
|
|
3c17e71b63 | ||
|
|
1d46986e80 | ||
|
|
ca1d62719a | ||
|
|
a6bea3572e | ||
|
|
ae933edba5 | ||
|
|
93c79df2df | ||
|
|
3e9fe17fcd | ||
|
|
874dca8499 | ||
|
|
c7bd9fa995 | ||
|
|
4446d02063 | ||
|
|
97c3d193a1 | ||
|
|
65e0f704fd | ||
|
|
d36c0dde5b | ||
|
|
8ed3d2fe33 | ||
|
|
61d34a352c | ||
|
|
6c9a2582c6 | ||
|
|
0fd354cb39 | ||
|
|
fd8b7e3a6b | ||
|
|
0be8f439ef | ||
|
|
8a8ea3e23a | ||
|
|
70b5d0d0af | ||
|
|
06ee050fb2 | ||
|
|
472bd4cb12 | ||
|
|
fed696dc63 | ||
|
|
35da61660b | ||
|
|
0ef7755151 | ||
|
|
7aa4309848 | ||
|
|
3c21bf00ac | ||
|
|
0f303d5c06 | ||
|
|
cfbd07306d | ||
|
|
cd8efa604f | ||
|
|
af637a28d8 | ||
|
|
0cefcae153 | ||
|
|
b42a909e65 | ||
|
|
dace0f70ef | ||
|
|
43329f557f | ||
|
|
3e8b836b3e | ||
|
|
ead7c6c8c3 | ||
|
|
fc3bcf0578 | ||
|
|
68cca0e222 | ||
|
|
bfe5219dc2 | ||
|
|
ae6f9d9310 | ||
|
|
f8b786ac40 | ||
|
|
53a2bcdd8b | ||
|
|
f11d325641 | ||
|
|
aa6cbe2d72 | ||
|
|
50e2cdb527 | ||
|
|
1f184eae8c | ||
|
|
90f3c5ce26 | ||
|
|
aa85c396bf | ||
|
|
f19cfecebe | ||
|
|
7456652b67 | ||
|
|
29f87a6d58 | ||
|
|
880a42bb90 |
@@ -1,6 +1,8 @@
|
||||
name: STEPCODE
|
||||
|
||||
on: [push]
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
@@ -183,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
|
||||
@@ -240,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
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-v][a-z]
|
||||
[._]sw[a-p]
|
||||
**/__pycache__/
|
||||
|
||||
# OS specific files
|
||||
.DS_Store
|
||||
|
||||
@@ -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)
|
||||
|
||||
+2
-8
@@ -48,7 +48,7 @@ endif (POLICY CMP0077)
|
||||
|
||||
# SC version
|
||||
set(SC_VERSION_MAJOR 0)
|
||||
set(SC_VERSION_MINOR 9)
|
||||
set(SC_VERSION_MINOR 8)
|
||||
set(SC_VERSION_PATCH 1)
|
||||
set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH})
|
||||
|
||||
@@ -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)
|
||||
@@ -153,7 +152,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 +173,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)
|
||||
@@ -193,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)
|
||||
|
||||
+4
-1
@@ -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
|
||||
|
||||
|
||||
@@ -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,9 +111,9 @@ 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)
|
||||
target_compile_definitions("${PROJECT_NAME}-static" PRIVATE SC_STATIC)
|
||||
if(MSVC)
|
||||
target_compile_options("${PROJECT_NAME}-static" PRIVATE "/bigobj")
|
||||
endif()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -14,20 +14,25 @@
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
# include "expparse.h"
|
||||
# include "expscan.h"
|
||||
# include "express/scope.h"
|
||||
# include "genCxxFilenames.h"
|
||||
# include "sc_mkdir.h"
|
||||
#define _XOPEN_SOURCE /* for S_IFDIR */
|
||||
|
||||
# include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
# ifdef _WIN32
|
||||
# include <direct.h>
|
||||
# define getcwd _getcwd
|
||||
# else
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
#include "expparse.h"
|
||||
#include "expscan.h"
|
||||
#include "express/scope.h"
|
||||
#include "genCxxFilenames.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <direct.h>
|
||||
# define getcwd _getcwd
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
}
|
||||
|
||||
#include <string>
|
||||
@@ -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 ) {
|
||||
@@ -220,7 +249,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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -32,10 +32,9 @@ 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
|
||||
install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/config.h
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode)
|
||||
|
||||
# Local Variables:
|
||||
|
||||
@@ -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
|
||||
@@ -14,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
|
||||
@@ -26,5 +26,6 @@
|
||||
|
||||
#cmakedefine HAVE_STD_THREAD 1
|
||||
#cmakedefine HAVE_STD_CHRONO 1
|
||||
#cmakedefine HAVE_NULLPTR 1
|
||||
|
||||
#endif /* SCL_CF_H */
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef EXPPP_H
|
||||
#define EXPPP_H
|
||||
|
||||
#include <sc_stdbool.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sc_cf.h>
|
||||
#include "config.h"
|
||||
#include <sc_export.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# include <sc_stdbool.h>
|
||||
# include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__cplusplus)
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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_*/
|
||||
@@ -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
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
|
||||
#include "path2str.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include <string.h>
|
||||
|
||||
/* 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;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef PATH2STR_H
|
||||
#define PATH2STR_H
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
/** 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 */
|
||||
@@ -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 <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -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 */
|
||||
@@ -1,405 +0,0 @@
|
||||
|
||||
#define SC_MEMMGR_CC
|
||||
|
||||
#include <sc_cf.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#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_error> sc_memmgr_errors;
|
||||
typedef std::set<sc_memmgr_error>::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_record> sc_memmgr_records;
|
||||
typedef std::set<sc_memmgr_record>::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 */
|
||||
@@ -1,79 +0,0 @@
|
||||
#ifndef SC_MEMMGR_H
|
||||
#define SC_MEMMGR_H
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(SC_MEMMGR_ENABLE_CHECKS)
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <stddef.h>
|
||||
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 <new>
|
||||
|
||||
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 */
|
||||
@@ -1,32 +0,0 @@
|
||||
#define _XOPEN_SOURCE /* for S_IFDIR */
|
||||
#include "sc_mkdir.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#ifdef _WIN32
|
||||
# include <direct.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* cross-platform mkdir */
|
||||
int sc_mkdir( const char * path ) {
|
||||
#ifdef _WIN32
|
||||
return mkdir( path );
|
||||
#else
|
||||
return mkdir( path, 0777 );
|
||||
#endif /* _WIN32 */
|
||||
}
|
||||
|
||||
/* return -1 if error, 0 if created, 1 if dir existed already */
|
||||
int mkDirIfNone( const char * path ) {
|
||||
struct stat s;
|
||||
if( stat( path, &s ) != 0 ) {
|
||||
if( errno == ENOENT ) {
|
||||
return sc_mkdir( path );
|
||||
}
|
||||
} else if( s.st_mode & S_IFDIR ) {
|
||||
return 1;
|
||||
}
|
||||
/* either stat returned an error other than ENOENT, or 'path' exists but isn't a dir */
|
||||
return -1;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef SC_MKDIR
|
||||
#define SC_MKDIR
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
/** cross-platform mkdir() */
|
||||
SC_BASE_EXPORT int sc_mkdir( const char * path );
|
||||
|
||||
/** create a dir 'path' if 'path' doesn't exist
|
||||
* \return -1 if error, 0 if created, 1 if dir existed already
|
||||
* if it returns -1, check errno
|
||||
*/
|
||||
SC_BASE_EXPORT int mkDirIfNone( const char * path );
|
||||
|
||||
#endif /* SC_MKDIR */
|
||||
@@ -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 <stdarg.h>
|
||||
|
||||
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 */
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef SC_STRTOULL_H
|
||||
#define SC_STRTOULL_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# define strtoull _strtoui64
|
||||
# define ULLONG_MAX _UI64_MAX
|
||||
#endif
|
||||
|
||||
#endif /* SC_STRTOULL_H */
|
||||
@@ -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})
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
#include "sdaiApplication_instance.h"
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <sstream>
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_Binary::SDAI_Binary( const char * str, int max ) {
|
||||
content = std::string( str, max );
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
// to help ObjectCenter
|
||||
#ifndef HAVE_MEMMOVE
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
//#include <EntityExtent.h>
|
||||
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_Entity_extent::SDAI_Entity_extent( )
|
||||
: _definition( 0 ), _definition_name( 0 ), _owned_by( 0 ) {
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
/*
|
||||
#include <EntityExtent.h>
|
||||
@@ -51,7 +50,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 +61,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
/*
|
||||
* NIST STEP Core Class Library
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
///////// SDAI_Model_contents_instances
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
* UArray implementation.
|
||||
*/
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
// to help ObjectCenter
|
||||
#ifndef HAVE_MEMMOVE
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_sdaiObject::SDAI_sdaiObject() {
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_Session_instance::SDAI_Session_instance() {
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <sdai.h>
|
||||
#include <sstream>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_String::SDAI_String( const char * str, size_t max ) {
|
||||
if( !str ) {
|
||||
|
||||
@@ -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}
|
||||
|
||||
+27
-10
@@ -34,8 +34,6 @@
|
||||
// void PushPastString (istream& in, std::string &s, ErrorDescriptor *err)
|
||||
#include <STEPundefined.h>
|
||||
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
/**
|
||||
* \returns The new file name for the class.
|
||||
* \param newName The file name to be set.
|
||||
@@ -117,7 +115,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 +440,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 +563,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 +728,7 @@ int STEPfile::FindDataSection( istream & in ) {
|
||||
}
|
||||
|
||||
int STEPfile::FindHeaderSection( istream & in ) {
|
||||
char buf[BUFSIZ];
|
||||
char buf[BUFSIZ+1];
|
||||
char * b = buf;
|
||||
|
||||
*b = '\0';
|
||||
@@ -851,6 +849,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 +879,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 +889,10 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou
|
||||
SkipInstance( in, tmpbuf );
|
||||
|
||||
ReadTokenSeparator( in );
|
||||
|
||||
if (scopelist)
|
||||
delete[] scopelist;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -1150,7 +1156,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;
|
||||
@@ -1531,9 +1537,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 +1561,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 +1574,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 +1589,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 ) {
|
||||
@@ -1603,7 +1620,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;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <cmath>
|
||||
|
||||
#include <cstring>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
extern void HeaderSchemaInit( Registry & reg );
|
||||
|
||||
@@ -179,7 +178,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 +195,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 +230,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 );
|
||||
|
||||
@@ -13,7 +13,6 @@ extern ofstream * logStream;
|
||||
#include <ExpDict.h>
|
||||
#include <STEPattribute.h>
|
||||
#include <SdaiHeaderSchema.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
Schema * s_header_section_schema = 0;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// regenerate it.
|
||||
|
||||
#include <SdaiHeaderSchema.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
void HeaderInitSchemasAndEnts( Registry & reg ) {
|
||||
Uniqueness_rule_ptr ur;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <ExpDict.h>
|
||||
#include <STEPattribute.h>
|
||||
#include <SdaiHeaderSchema.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) {
|
||||
header_section_schemat_time_stamp_text->ReferentType( t_sdaiSTRING );
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// regenerate it.
|
||||
|
||||
#include <SdaiSchemaInit.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
void HeaderSchemaInit( Registry & reg ) {
|
||||
HeaderInitSchemasAndEnts( reg );
|
||||
|
||||
+10
-1
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include <cmdmgr.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
ReplicateLinkNode * ReplicateList::FindNode( MgrNode * mn ) {
|
||||
ReplicateLinkNode * rln = ( ReplicateLinkNode * )GetHead();
|
||||
@@ -72,6 +71,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 );
|
||||
|
||||
@@ -145,6 +145,7 @@ class SC_EDITOR_EXPORT CmdMgr {
|
||||
public:
|
||||
|
||||
CmdMgr();
|
||||
~CmdMgr();
|
||||
|
||||
// STATE LIST OPERATIONS
|
||||
MgrNode * GetHead( stateEnum listType );
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "lazyFileReader.h"
|
||||
#include "sectionReader.h"
|
||||
#include "lazyTypes.h"
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
#include "sc_export.h"
|
||||
|
||||
@@ -31,6 +30,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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <iostream>
|
||||
#include "sectionReader.h"
|
||||
#include "lazyTypes.h"
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
#include "sc_export.h"
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
* #include "lazyP28DataSectionReader.h"
|
||||
* #include "p28HeaderSectionReader.h"
|
||||
*/
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
class lazyInstMgr;
|
||||
class Registry;
|
||||
class headerSectionReader;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "lazyTypes.h"
|
||||
|
||||
#include "Registry.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include "sc_export.h"
|
||||
|
||||
#include "judyLArray.h"
|
||||
|
||||
@@ -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 ) ) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef LAZYTYPES_H
|
||||
#define LAZYTYPES_H
|
||||
|
||||
#include "sc_cf.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "lazyInstMgr.h"
|
||||
#include <sc_benchmark.h>
|
||||
#include "./sc_benchmark.h"
|
||||
#include "SdaiSchemaInit.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include <sc_cf.h>
|
||||
#include "config.h"
|
||||
|
||||
#ifndef NO_REGISTRY
|
||||
# include "schema.h"
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 <windows.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 <iostream>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
#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
|
||||
@@ -5,9 +5,14 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
#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"
|
||||
@@ -26,11 +31,14 @@ 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;
|
||||
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 +92,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 +122,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 +184,7 @@ void sectionReader::locateAllInstances() {
|
||||
}
|
||||
|
||||
instanceID sectionReader::readInstanceNumber() {
|
||||
char c;
|
||||
int c;
|
||||
size_t digits = 0;
|
||||
instanceID id = 0;
|
||||
|
||||
@@ -221,7 +229,7 @@ instanceID sectionReader::readInstanceNumber() {
|
||||
_error->UserMsg( "A very large instance ID encountered" );
|
||||
_error->DetailMsg( errorMsg.str() );
|
||||
|
||||
delete buffer;
|
||||
delete[] buffer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -251,7 +259,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;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include "lazyTypes.h"
|
||||
#include "sc_memmgr.h"
|
||||
#include "sc_export.h"
|
||||
#include "errordesc.h"
|
||||
#include "STEPcomplex.h"
|
||||
@@ -38,6 +37,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
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <ExpDict.h>
|
||||
#include <Registry.h>
|
||||
#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 */
|
||||
@@ -79,7 +78,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 );
|
||||
@@ -235,13 +234,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,10 @@ 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;
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <STEPattribute.h>
|
||||
#include <instmgr.h>
|
||||
#include <ExpDict.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -106,7 +105,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;
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <STEPaggregate.h>
|
||||
#include <ExpDict.h>
|
||||
#include <sdai.h>
|
||||
#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
|
||||
@@ -1263,20 +1262,20 @@ 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 ) {
|
||||
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 );
|
||||
}
|
||||
}
|
||||
@@ -1293,7 +1292,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 );
|
||||
@@ -1304,12 +1303,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 +1464,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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
#include <STEPattributeList.h>
|
||||
#include <STEPattribute.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
AttrListNode::AttrListNode( STEPattribute * a ) {
|
||||
attr = a;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <STEPattribute.h>
|
||||
#include <STEPaggregate.h>
|
||||
#include <sstream>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
extern const char *
|
||||
ReadStdKeyword( istream & in, std::string & buf, int skipInitWS );
|
||||
@@ -20,7 +19,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 +60,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 +658,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 +699,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,
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include <STEPinvAttrList.h>
|
||||
#include <ExpDict.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
invAttrListNodeI::invAttrListNodeI(Inverse_attribute* a, setterI_t s, getterI_t g): invAttrListNode(a), set( s ), get( g ) {}
|
||||
invAttrListNodeA::invAttrListNodeA(Inverse_attribute* a, setterA_t s, getterA_t g): invAttrListNode(a), set( s ), get( g ) {}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <stdio.h> // to get the BUFSIZ #define
|
||||
#include <STEPattribute.h>
|
||||
#include <STEPundefined.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
/** \class SCLundefined
|
||||
** helper functions for reading unknown types
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include <SingleLinkList.h>
|
||||
#include "sc_memmgr.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
@@ -95,7 +94,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 +110,7 @@ void SingleLinkList::DeleteNode( SingleLinkNode * item ) {
|
||||
tail = trailer;
|
||||
}
|
||||
delete item;
|
||||
return;
|
||||
} else {
|
||||
if( trailer ) {
|
||||
trailer = trailer->NextNode();
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
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();
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "complexSupport.h"
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
/**
|
||||
* Inserts a new ComplexList to our list. The ComplexLists are ordered by
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user