Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86064385df |
@@ -1,8 +1,6 @@
|
||||
name: STEPCODE
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
@@ -185,9 +183,9 @@ jobs:
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/BRL-CAD/brlcad.git -b main
|
||||
git clone --depth 1 git://github.com/BRL-CAD/brlcad.git -b main
|
||||
cd brlcad/src/other/ext && rm -rf stepcode
|
||||
git clone --depth 1 https://github.com/stepcode/stepcode.git -b develop
|
||||
git clone --depth 1 git://github.com/stepcode/stepcode.git -b develop
|
||||
# Ordinarily BRL-CAD keeps track of what files are supposed to be
|
||||
# present in the repository. In this case we're not interested in
|
||||
# updating the list to the working stepcode filelist, so use an empty
|
||||
@@ -242,10 +240,10 @@ jobs:
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone --depth 1 https://github.com/BRL-CAD/brlcad.git -b main
|
||||
git clone --depth 1 git://github.com/BRL-CAD/brlcad.git -b main
|
||||
cd brlcad/src/other/ext
|
||||
cmake -E rm -r stepcode
|
||||
git clone --depth 1 https://github.com/stepcode/stepcode.git -b develop
|
||||
git clone --depth 1 git://github.com/stepcode/stepcode.git -b develop
|
||||
# Ordinarily BRL-CAD keeps track of what files are supposed to be
|
||||
# present in the repository. In this case we're not interested in
|
||||
# updating the list to the working stepcode filelist, so use an empty
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-v][a-z]
|
||||
[._]sw[a-p]
|
||||
**/__pycache__/
|
||||
|
||||
# OS specific files
|
||||
.DS_Store
|
||||
|
||||
@@ -19,7 +19,6 @@ 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)
|
||||
|
||||
+8
-2
@@ -48,7 +48,7 @@ endif (POLICY CMP0077)
|
||||
|
||||
# SC version
|
||||
set(SC_VERSION_MAJOR 0)
|
||||
set(SC_VERSION_MINOR 8)
|
||||
set(SC_VERSION_MINOR 9)
|
||||
set(SC_VERSION_PATCH 1)
|
||||
set(SC_VERSION ${SC_VERSION_MAJOR}.${SC_VERSION_MINOR}.${SC_VERSION_PATCH})
|
||||
|
||||
@@ -120,6 +120,7 @@ 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)
|
||||
@@ -152,7 +153,7 @@ include(SC_Locale)
|
||||
# logic related to regenerating the lexer and parser source code
|
||||
include(SC_Regenerate)
|
||||
|
||||
# create config.h header
|
||||
# create config header sc_cf.h
|
||||
include(SC_Config_Headers)
|
||||
|
||||
if(NOT DEFINED SC_SDAI_ADDITIONAL_EXES_SRCS)
|
||||
@@ -173,6 +174,10 @@ 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)
|
||||
@@ -188,6 +193,7 @@ include_directories(
|
||||
${SC_BINARY_DIR}/include
|
||||
)
|
||||
|
||||
add_subdirectory(src/base)
|
||||
add_subdirectory(src/express)
|
||||
add_subdirectory(src/exppp)
|
||||
add_subdirectory(src/exp2cxx)
|
||||
|
||||
+1
-4
@@ -11,12 +11,9 @@ 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.
|
||||
- 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`.
|
||||
* 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`.
|
||||
|
||||
## Coding Standards
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
***********************************************************************
|
||||
STEPcode v0.8 -- github.com/stepcode/stepcode
|
||||
|
||||
* test PR integration
|
||||
|
||||
* What is STEPcode? SC reads ISO10303-11 EXPRESS schemas and generates
|
||||
C++ source code that can read and write Part 21 files conforming
|
||||
to that schema. In addition to C++, SC includes experimental
|
||||
|
||||
@@ -141,7 +141,7 @@ if (LEMON_EXECUTABLE)
|
||||
|
||||
# execute lemon
|
||||
add_custom_command(
|
||||
OUTPUT ${_out_src_file} ${_basename}.h
|
||||
OUTPUT ${_out_src_file}
|
||||
COMMAND ${LEMON_EXECUTABLE} -T${LEMON_TEMPLATE} ${LEMON_EXECUTABLE_opts} ${_in_y_file}
|
||||
DEPENDS ${Name}_input_cpy
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
@@ -152,7 +152,7 @@ if (LEMON_EXECUTABLE)
|
||||
add_custom_command(
|
||||
OUTPUT ${_out_hdr_file}
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E rename ${_basename}.h ${_out_hdr_file}
|
||||
DEPENDS ${_out_src_file} ${_basename}.h
|
||||
DEPENDS ${_out_src_file}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
|
||||
@@ -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;${RELATIVE_PATH_COMPONENT}/src/test/p21read/sc_benchmark.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils TESTABLE)
|
||||
SC_ADDEXEC(p21read_${PROJECT_NAME} SOURCES "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base TESTABLE)
|
||||
if(NOT WIN32)
|
||||
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)
|
||||
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)
|
||||
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 TESTABLE)
|
||||
SC_ADDEXEC(${name}_${PROJECT_NAME} SOURCES ${src} LINK_LIBRARIES ${PROJECT_NAME} stepdai stepcore stepeditor steputils base 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/cllazyfile
|
||||
${SC_SOURCE_DIR}/src/cllazyfile/judy/src
|
||||
${SC_SOURCE_DIR}/src/clutils ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/base/judy/src
|
||||
)
|
||||
# if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation
|
||||
if(BUILD_SHARED_LIBS)
|
||||
SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils TESTABLE)
|
||||
SC_ADDLIB(${PROJECT_NAME} SHARED SOURCES ${sourceFiles} LINK_LIBRARIES stepdai stepcore stepeditor steputils base TESTABLE)
|
||||
add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME})
|
||||
if(WIN32)
|
||||
target_compile_definitions("${PROJECT_NAME}" PRIVATE SC_SCHEMA_DLL_EXPORTS)
|
||||
@@ -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 TESTABLE)
|
||||
SC_ADDLIB(${PROJECT_NAME}-static STATIC SOURCES ${sourceFiles} LINK_LIBRARIES stepdai-static stepcore-static stepeditor-static steputils-static base-static TESTABLE)
|
||||
add_dependencies(${PROJECT_NAME}-static generate_cpp_${PROJECT_NAME})
|
||||
target_compile_definitions("${PROJECT_NAME}-static" PRIVATE SC_STATIC)
|
||||
target_compile_defines("${PROJECT_NAME}-static" PRIVATE SC_STATIC)
|
||||
if(MSVC)
|
||||
target_compile_options("${PROJECT_NAME}-static" PRIVATE "/bigobj")
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# create config.h
|
||||
# create sc_cf.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 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)
|
||||
# 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)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
|
||||
@@ -16,6 +16,7 @@ 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
|
||||
@@ -51,6 +52,7 @@ 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,25 +14,20 @@
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#define _XOPEN_SOURCE /* for S_IFDIR */
|
||||
# include "expparse.h"
|
||||
# include "expscan.h"
|
||||
# include "express/scope.h"
|
||||
# include "genCxxFilenames.h"
|
||||
# include "sc_mkdir.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
# include <string.h>
|
||||
|
||||
#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
|
||||
# ifdef _WIN32
|
||||
# include <direct.h>
|
||||
# define getcwd _getcwd
|
||||
# else
|
||||
# include <unistd.h>
|
||||
# endif
|
||||
}
|
||||
|
||||
#include <string>
|
||||
@@ -130,30 +125,6 @@ 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 ) {
|
||||
@@ -249,7 +220,7 @@ void writeLists( const char * schemaName, stringstream & eh, stringstream & ei,
|
||||
|
||||
cmLists.close();
|
||||
|
||||
char pwd[BUFSIZ+1] = {0};
|
||||
char pwd[BUFSIZ] = {0};
|
||||
if( getcwd( pwd, BUFSIZ ) ) {
|
||||
cout << pwd << "/" << shortName << endl;
|
||||
} else {
|
||||
|
||||
@@ -51,13 +51,18 @@ 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 stepcore stepeditor stepdai steputils ${SCHEMA_LINK_NAME})
|
||||
set(STEPCODE_LIBRARIES base stepcore stepeditor stepdai steputils ${SCHEMA_LINK_NAME})
|
||||
|
||||
# Add STEPCode project to CMake build.
|
||||
add_subdirectory(${STEPCODE_ROOT_DIR} "${CMAKE_CURRENT_BINARY_DIR}/sc" EXCLUDE_FROM_ALL)
|
||||
|
||||
# Set up STEPcode include directories.
|
||||
set(STEPCODE_INCLUDE_DIR
|
||||
${STEPCODE_ROOT_DIR}/src/base
|
||||
${STEPCODE_ROOT_DIR}/src/clstepcore
|
||||
${STEPCODE_ROOT_DIR}/src/cldai
|
||||
${STEPCODE_ROOT_DIR}/src/clutils
|
||||
${STEPCODE_ROOT_DIR}/src/cleditor
|
||||
${STEPCODE_BUILD_DIR}/include
|
||||
${STEPCODE_ROOT_DIR}/include
|
||||
${CMAKE_BINARY_DIR}
|
||||
|
||||
@@ -19,6 +19,7 @@ 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
|
||||
@@ -27,6 +28,7 @@ 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
|
||||
@@ -42,6 +44,7 @@ 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
|
||||
|
||||
@@ -49,15 +49,15 @@
|
||||
// $./AP203Minimum
|
||||
// AP203Minimum outfile.stp
|
||||
|
||||
#include <cleditor/STEPfile.h>
|
||||
#include <clstepcore/sdai.h>
|
||||
#include <clstepcore/STEPattribute.h>
|
||||
#include <clstepcore/ExpDict.h>
|
||||
#include <clstepcore/Registry.h>
|
||||
#include <clutils/errordesc.h>
|
||||
#include <STEPfile.h>
|
||||
#include <sdai.h>
|
||||
#include <STEPattribute.h>
|
||||
#include <ExpDict.h>
|
||||
#include <Registry.h>
|
||||
#include <errordesc.h>
|
||||
|
||||
#include <clstepcore/STEPcomplex.h>
|
||||
#include <cleditor/SdaiHeaderSchema.h>
|
||||
#include <STEPcomplex.h>
|
||||
#include <SdaiHeaderSchema.h>
|
||||
|
||||
#include "schema.h"
|
||||
|
||||
|
||||
@@ -32,17 +32,12 @@ 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}/config.h
|
||||
install(FILES ${SC_BINARY_DIR}/${INCLUDE_DIR}/sc_cf.h
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode)
|
||||
|
||||
add_subdirectory(cldai)
|
||||
add_subdirectory(cleditor)
|
||||
add_subdirectory(cllazyfile)
|
||||
add_subdirectory(clstepcore)
|
||||
add_subdirectory(clutils)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
set(DAI_HDRS
|
||||
sdaiApplication_instance_set.h
|
||||
sdaiBinary.h
|
||||
sdaiDaObject.h
|
||||
sdaiEntity_extent.h
|
||||
sdaiEntity_extent_set.h
|
||||
sdaiEnum.h
|
||||
sdaiModel_contents.h
|
||||
sdaiModel_contents_list.h
|
||||
sdaiObject.h
|
||||
sdaiSession_instance.h
|
||||
sdaiString.h
|
||||
)
|
||||
|
||||
install(FILES ${DAI_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/cldai)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
set(EDITOR_HDRS
|
||||
STEPfile.h
|
||||
cmdmgr.h
|
||||
editordefines.h
|
||||
SdaiHeaderSchema.h
|
||||
SdaiHeaderSchemaClasses.h
|
||||
SdaiSchemaInit.h
|
||||
seeinfodefault.h
|
||||
)
|
||||
|
||||
install(FILES ${EDITOR_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/cleditor)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
set(LAZY_HDRS
|
||||
headerSectionReader.h
|
||||
lazyFileReader.h
|
||||
lazyP21DataSectionReader.h
|
||||
p21HeaderSectionReader.h
|
||||
lazyDataSectionReader.h
|
||||
lazyInstMgr.h
|
||||
lazyTypes.h
|
||||
sectionReader.h
|
||||
instMgrHelper.h
|
||||
judy.h
|
||||
judyL2Array.h
|
||||
judyLArray.h
|
||||
judyS2Array.h
|
||||
judySArray.h
|
||||
)
|
||||
|
||||
install(FILES ${LAZY_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/cllazyfile)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
set(CORE_HDRS
|
||||
aggrTypeDescriptor.h
|
||||
attrDescriptor.h
|
||||
attrDescriptorList.h
|
||||
baseType.h
|
||||
complexSupport.h
|
||||
create_Aggr.h
|
||||
derivedAttribute.h
|
||||
dictSchema.h
|
||||
dictdefs.h
|
||||
dictionaryInstance.h
|
||||
dispnode.h
|
||||
dispnodelist.h
|
||||
entityDescriptor.h
|
||||
entityDescriptorList.h
|
||||
enumTypeDescriptor.h
|
||||
ExpDict.h
|
||||
explicitItemId.h
|
||||
globalRule.h
|
||||
implicitItemId.h
|
||||
instmgr.h
|
||||
interfaceSpec.h
|
||||
interfacedItem.h
|
||||
inverseAttribute.h
|
||||
inverseAttributeList.h
|
||||
mgrnode.h
|
||||
mgrnodearray.h
|
||||
mgrnodelist.h
|
||||
needFunc.h
|
||||
read_func.h
|
||||
realTypeDescriptor.h
|
||||
Registry.h
|
||||
schRename.h
|
||||
sdai.h
|
||||
sdaiApplication_instance.h
|
||||
sdaiSelect.h
|
||||
selectTypeDescriptor.h
|
||||
SingleLinkList.h
|
||||
STEPaggregate.h
|
||||
STEPaggrBinary.h
|
||||
STEPaggrEntity.h
|
||||
STEPaggrEnum.h
|
||||
STEPaggrGeneric.h
|
||||
STEPaggrInt.h
|
||||
STEPaggrReal.h
|
||||
STEPaggrSelect.h
|
||||
STEPaggrString.h
|
||||
STEPattribute.h
|
||||
STEPattributeList.h
|
||||
STEPcomplex.h
|
||||
STEPinvAttrList.h
|
||||
STEPundefined.h
|
||||
stringTypeDescriptor.h
|
||||
SubSuperIterators.h
|
||||
typeDescriptor.h
|
||||
typeDescriptorList.h
|
||||
typeOrRuleVar.h
|
||||
uniquenessRule.h
|
||||
whereRule.h
|
||||
)
|
||||
|
||||
install(FILES ${CORE_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/clstepcore)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
set(UTILS_HDRS
|
||||
dirobj.h
|
||||
errordesc.h
|
||||
gennodearray.h
|
||||
gennode.h
|
||||
gennodelist.h
|
||||
sc_hash.h
|
||||
Str.h
|
||||
)
|
||||
|
||||
install(FILES ${UTILS_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/clutils)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef EXPPP_H
|
||||
#define EXPPP_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sc_stdbool.h>
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <sc_cf.h>
|
||||
#include <sc_export.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# include <stdbool.h>
|
||||
# include <sc_stdbool.h>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900) && !defined(__cplusplus)
|
||||
@@ -96,8 +96,5 @@
|
||||
typedef void ( *voidFuncptr )();
|
||||
typedef int ( *intFuncptr )();
|
||||
|
||||
/* Option index - can we get rid of this? */
|
||||
extern SC_EXPRESS_EXPORT int sc_optind;
|
||||
|
||||
#endif /* BASIC_H */
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
/***************************/
|
||||
|
||||
struct Object {
|
||||
struct Symbol_ * ( *get_symbol )( void * );
|
||||
struct Symbol_ * ( *get_symbol )();
|
||||
char * type; /**< should complete the phrase "X is ..." - i.e., "an entity", "a type", "of unknown type" */
|
||||
int bits; /**< a bitwise selector of a type, i.e. OBJ_XX_BITS */
|
||||
};
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#cmakedefine HAVE_IO_H 1
|
||||
|
||||
#cmakedefine SC_TRACE_FPRINTF 1
|
||||
#cmakedefine SC_MEMMGR_ENABLE_CHECKS 1
|
||||
|
||||
#cmakedefine HAVE_ABS 1
|
||||
#cmakedefine HAVE_MEMCPY 1
|
||||
@@ -2,7 +2,6 @@
|
||||
#define SCL_CF_H
|
||||
|
||||
/**** Define statements for CMake ****/
|
||||
#cmakedefine SC_VERSION "@SC_VERSION@"
|
||||
#cmakedefine HAVE_NDIR_H 1
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
#cmakedefine HAVE_SYS_STAT_H 1
|
||||
@@ -15,6 +14,7 @@
|
||||
#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,6 +26,5 @@
|
||||
|
||||
#cmakedefine HAVE_STD_THREAD 1
|
||||
#cmakedefine HAVE_STD_CHRONO 1
|
||||
#cmakedefine HAVE_NULLPTR 1
|
||||
|
||||
#endif /* SCL_CF_H */
|
||||
@@ -0,0 +1,43 @@
|
||||
#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,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"utils\/$1\"/g" {} \;
|
||||
find . -type f -path "*/cl*" -not -path "*.git/*" -not -path "*/exp*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"utils\/$1\"/g" {} \;
|
||||
|
||||
find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"utils\/$1\"/g" {} \;
|
||||
find . -type f -path "*/include*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"utils\/$1\"/g" {} \;
|
||||
|
||||
find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include \"$1\"/include \"utils\/$1\"/g" {} \;
|
||||
find . -type f -path "*/test*" -not -path "*.git/*" -regex '.*\(c\|cc\|cpp\|cxx\|h\|hpp\)$' -exec perl -0777 -pi -e "s/include <$1>/include \"utils\/$1\"/g" {} \;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
|
||||
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
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project( JudyTemplates )
|
||||
|
||||
if( NOT DEFINED CMAKE_BUILD_TYPE )
|
||||
# set( CMAKE_BUILD_TYPE "RelWithDebInfo" ) #optimize, but include debug info
|
||||
set( CMAKE_BUILD_TYPE "Release" )
|
||||
endif( NOT DEFINED CMAKE_BUILD_TYPE )
|
||||
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
|
||||
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
|
||||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
|
||||
|
||||
if( NOT DEFINED JUDY_OPTIMIZE_FLAGS )
|
||||
if( CMAKE_COMPILER_IS_GNUCC )
|
||||
set( JUDY_OPTIMIZE_FLAGS "-march=native" )
|
||||
|
||||
#test for LTO; this uses an internal variable so it may break
|
||||
if( DEFINED CMAKE_C_COMPILER_VERSION )
|
||||
if( ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 4.7.0 )
|
||||
set( JUDY_OPTIMIZE_FLAGS "${JUDY_OPTIMIZE_FLAGS} -flto" )
|
||||
message( " -- GCC version: ${CMAKE_C_COMPILER_VERSION}. Enabling link-time optimization." )
|
||||
endif( ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 4.7.0 )
|
||||
endif( DEFINED CMAKE_C_COMPILER_VERSION )
|
||||
#elseif( MSVC )
|
||||
# set( JUDY_OPTIMIZE_FLAGS "..." ) # <--- set MSVC flags here <---
|
||||
else()
|
||||
message( "Unrecognized compiler - no optimization flags set. Edit CMakeLists.txt or set JUDY_OPTIMIZE_FLAGS." )
|
||||
set( JUDY_OPTIMIZE_FLAGS "" )
|
||||
endif( CMAKE_COMPILER_IS_GNUCC )
|
||||
endif( NOT DEFINED JUDY_OPTIMIZE_FLAGS )
|
||||
add_definitions( ${JUDY_OPTIMIZE_FLAGS} )
|
||||
|
||||
set( JUDYS_SOURCES src/judy.c src/judy.h )
|
||||
|
||||
if( CMAKE_COMPILER_IS_GNUCC )
|
||||
add_definitions( -pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long )
|
||||
endif( CMAKE_COMPILER_IS_GNUCC )
|
||||
|
||||
add_library( judy_lib STATIC ${JUDYS_SOURCES} )
|
||||
|
||||
include_directories( src )
|
||||
|
||||
if( ENABLE_TESTING )
|
||||
include( CTest )
|
||||
include_directories( test )
|
||||
enable_testing()
|
||||
|
||||
add_executable( pennysort test/pennySort.c test/sort.c ${JUDYS_SOURCES} )
|
||||
add_executable( hexsort test/hexSort.c test/sort.c ${JUDYS_SOURCES} )
|
||||
set_target_properties( pennysort hexsort PROPERTIES COMPILE_FLAGS "-DSTANDALONE" )
|
||||
|
||||
|
||||
add_executable( judyLtest test/judyLtest.cc )
|
||||
target_link_libraries( judyLtest judy_lib )
|
||||
add_test( judyLtest judyLtest )
|
||||
|
||||
add_executable( judyL2test test/judyL2test.cc )
|
||||
target_link_libraries( judyL2test judy_lib )
|
||||
add_test( judyL2test judyL2test )
|
||||
|
||||
add_executable( judyStest test/judyStest.cc )
|
||||
target_link_libraries( judyStest judy_lib )
|
||||
add_test( judyStest judyStest )
|
||||
|
||||
add_executable( judyS2test test/judyS2test.cc )
|
||||
target_link_libraries( judyS2test judy_lib )
|
||||
add_test( judyS2test judyS2test )
|
||||
|
||||
endif( ENABLE_TESTING )
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
# indent-tabs-mode: t
|
||||
# End:
|
||||
# ex: shiftwidth=2 tabstop=8
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# Judy Array Templates
|
||||
The Judy Array is a sparse dynamic array. It is a particular kind of trie that is highly efficient in space and time, and does not require tuning.
|
||||
|
||||
This uses [Karl Malbrain's implementation](http://code.google.com/p/judyarray/) of the Judy Array. Additional information can be found with Doug Baskins' [original implementation](http://judy.sourceforge.net/) on sourceforge, or on [Wikipedia](http://en.wikipedia.org/wiki/Judy_array).
|
||||
## The templates
|
||||
* `judyLArray` - a C++ template wrapper for an int-int Judy Array. JudyKey and JudyValue must be integer types and the same size as a pointer (i.e. 32- or 64-bit)
|
||||
* `judySArray` - Same as judyLArray, but with string-int mapping. The above restrictions on JudyValue apply here as well.
|
||||
* **TODO** - single-key, multi-value versions of the above
|
||||
* **TODO** - single-key, n-value versions of the above *(?)*
|
||||
|
||||
## Comparison between this and the versions Karl and Doug wrote
|
||||
* Doug Baskins' code is licenced under the LGPL. While more permissive than the GPL, it's still not always acceptable. His code is very fast but weighs in at ~20k lines.
|
||||
* Karl Malbrain's code is ~1250 lines, in a single file containing the judy array and the test code; use requires creating a header.
|
||||
* Both of the above are written in C, so they don't fit neatly into object-oriented C++.
|
||||
* Unlike Doug's code, this is ~1250 lines. Unlike Karl's, this is split into several files.
|
||||
|
||||
## Files
|
||||
* `CMakeLists.txt` - CMake build logic. If you don't have CMake, it should be quite easy to write a file for the build system of your choice.
|
||||
* **src/**
|
||||
* `judy.c`, `judy.h` - implementation of the Judy Array
|
||||
* `judyLArray.h` - the judyLArray template
|
||||
* `judySArray.h` - the judySArray template
|
||||
* **test/**
|
||||
* `hexSort.c` - Sorts a file where each line contains 32 hex chars. Compiles to `hexsort`, which is the same executable as compiling Karl's code with `-DHEXSORT -DSTANDALONE`
|
||||
* `pennySort.c` - Sorts strings; compiles to `pennysort`. Same as compiling Karl's code with `-DSTANDALONE`.
|
||||
* `sort.c`, `sort.h` - Karl's sorting functions. Only used by `hexsort` and `pennysort`.
|
||||
* `judyLtest.cc` - an incomplete test of the judyLArray template.
|
||||
* `judyStest.cc` - an incomplete test of the judySArray template.
|
||||
|
||||
|
||||
## Compiling
|
||||
* requires C and C++ compilers, CMake.
|
||||
* from the command line:
|
||||
* `mkdir build; cd build`
|
||||
* `cmake .. -DENABLE_TESTING=TRUE`
|
||||
* `make`
|
||||
|
||||
## License
|
||||
|
||||
Karl Malbrain's judy array code is public domain; what I've added is public domain as well.
|
||||
|
||||
## Contact
|
||||
mpictor -a-t- gmail
|
||||
@@ -0,0 +1,29 @@
|
||||
#astyle config file
|
||||
|
||||
#run astyle on one or a few files: use
|
||||
# astyle --options=misc/astyle.cfg path/to/file
|
||||
|
||||
#run astyle on all files: from the root dir, use
|
||||
# astyle --options=misc/astyle.cfg --recursive "src/*.c" "src/*.h" "test/*.c" "test/*.h"
|
||||
# in the above line, the double quotes *are* necessary
|
||||
|
||||
|
||||
suffix=none #don't create backup files
|
||||
|
||||
style=java #compact bracket style
|
||||
|
||||
indent=spaces=4
|
||||
|
||||
indent-preprocessor
|
||||
indent-classes
|
||||
indent-switches
|
||||
indent-namespaces
|
||||
pad-oper #pad (space) around operators
|
||||
pad-paren-in #pad inside parenthesis
|
||||
unpad-paren #remove parenthesis padding other than requested above
|
||||
|
||||
add-brackets #add brackets on one-line conditionals
|
||||
convert-tabs #convert all tabs to spaces
|
||||
align-pointer=middle #char * foo
|
||||
|
||||
lineend=linux #lines end with LF (linux), not CRLF (windows)
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
#generates a file of hex keys and runs hexsort on it. No verification is done.
|
||||
#hex data comes from /dev/urandom, so it isn't all that random.
|
||||
|
||||
hexdump -v -e '2/8 "%08x"' -e '"\n"' /dev/urandom |head -n 1000000 >ukeys
|
||||
#a.out [in-file] [out-file] [keysize] [recordlen] [keyoffset] [mergerecs]
|
||||
time bin/hexsort ukeys skeys
|
||||
File diff suppressed because it is too large
Load Diff
@@ -60,7 +60,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "cllazyfile/judy.h"
|
||||
#include "judy.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@@ -0,0 +1,124 @@
|
||||
// Judy arrays 13 DEC 2012 (judy64n.c from http://code.google.com/p/judyarray/ )
|
||||
// This code is public domain.
|
||||
|
||||
// Author Karl Malbrain, malbrain AT yahoo.com
|
||||
// with assistance from Jan Weiss.
|
||||
// modifications (and any bugs) by Mark Pictor, mpictor at gmail
|
||||
|
||||
// Simplified judy arrays for strings and integers
|
||||
// Adapted from the ideas of Douglas Baskins of HP.
|
||||
|
||||
// Map a set of keys to corresponding memory cells (uints).
|
||||
// Each cell must be set to a non-zero value by the caller.
|
||||
|
||||
|
||||
// Integer mappings are denoted by calling judy_open with the
|
||||
// Integer depth of the Judy Trie as the second argument.
|
||||
|
||||
#ifndef STANDALONE
|
||||
# error must define STANDALONE while compiling this file and judy64.c
|
||||
#endif
|
||||
|
||||
#include "judy.h"
|
||||
#include "sort.h"
|
||||
|
||||
unsigned int MaxMem = 0;
|
||||
/**
|
||||
usage:
|
||||
a.out [in-file] [out-file]
|
||||
where all lines of in-file are 32 chars, hexadecimal
|
||||
On linux, a 1M-line file can be created with the following:
|
||||
hexdump -v -e '2/8 "%08x"' -e '"\n"' /dev/urandom |head -n 1000000 >in-file
|
||||
*/
|
||||
int main( int argc, char ** argv ) {
|
||||
unsigned char buff[1024];
|
||||
JudySlot max = 0;
|
||||
JudySlot * cell;
|
||||
FILE * in, *out;
|
||||
void * judy;
|
||||
unsigned int len;
|
||||
unsigned int idx;
|
||||
|
||||
if( argc > 1 ) {
|
||||
in = fopen( argv[1], "rb" );
|
||||
} else {
|
||||
in = stdin;
|
||||
}
|
||||
|
||||
if( argc > 2 ) {
|
||||
out = fopen( argv[2], "wb" );
|
||||
} else {
|
||||
out = stdout;
|
||||
}
|
||||
|
||||
setvbuf( out, NULL, _IOFBF, 4096 * 1024 );
|
||||
|
||||
if( !in ) {
|
||||
fprintf( stderr, "unable to open input file\n" );
|
||||
}
|
||||
|
||||
if( !out ) {
|
||||
fprintf( stderr, "unable to open output file\n" );
|
||||
}
|
||||
|
||||
PennyMerge = ( unsigned long long )PennyLine * PennyRecs;
|
||||
|
||||
judy = judy_open( 1024, 16 / JUDY_key_size );
|
||||
|
||||
while( fgets( ( char * )buff, sizeof( buff ), in ) ) {
|
||||
judyvalue key[16 / JUDY_key_size];
|
||||
if( len = strlen( ( const char * )buff ) ) {
|
||||
buff[--len] = 0; // remove LF
|
||||
}
|
||||
#if JUDY_key_size == 4
|
||||
key[3] = strtoul( buff + 24, NULL, 16 );
|
||||
buff[24] = 0;
|
||||
key[2] = strtoul( buff + 16, NULL, 16 );
|
||||
buff[16] = 0;
|
||||
key[1] = strtoul( buff + 8, NULL, 16 );
|
||||
buff[8] = 0;
|
||||
key[0] = strtoul( buff, NULL, 16 );
|
||||
#else
|
||||
key[1] = strtoull( buff + 16, NULL, 16 );
|
||||
buff[16] = 0;
|
||||
key[0] = strtoull( buff, NULL, 16 );
|
||||
#endif
|
||||
*( judy_cell( judy, ( void * )key, 0 ) ) += 1; // count instances of string
|
||||
max++;
|
||||
}
|
||||
|
||||
fprintf( stderr, "%" PRIuint " memory used\n", MaxMem );
|
||||
|
||||
cell = judy_strt( judy, NULL, 0 );
|
||||
|
||||
if( cell ) do {
|
||||
judyvalue key[16 / JUDY_key_size];
|
||||
len = judy_key( judy, ( void * )key, 0 );
|
||||
for( idx = 0; idx < *cell; idx++ ) { // spit out duplicates
|
||||
#if JUDY_key_size == 4
|
||||
fprintf( out, "%.8X", key[0] );
|
||||
fprintf( out, "%.8X", key[1] );
|
||||
fprintf( out, "%.8X", key[2] );
|
||||
fprintf( out, "%.8X", key[3] );
|
||||
#else
|
||||
fprintf( out, "%.16llX", key[0] );
|
||||
fprintf( out, "%.16llX", key[1] );
|
||||
#endif
|
||||
fputc( '\n', out );
|
||||
}
|
||||
} while( cell = judy_nxt( judy ) );
|
||||
|
||||
#if 0
|
||||
// test deletion all the way to an empty tree
|
||||
|
||||
if( cell = judy_prv( judy ) )
|
||||
do {
|
||||
max -= *cell;
|
||||
} while( cell = judy_del( judy ) );
|
||||
|
||||
assert( max == 0 );
|
||||
#endif
|
||||
judy_close( judy );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "judyL2Array.h"
|
||||
typedef judyL2Array< uint64_t, uint64_t > jl2a;
|
||||
|
||||
bool testFind( jl2a & j, uint64_t key, unsigned int count ) {
|
||||
jl2a::cvector * v = j.find( key );
|
||||
std::cout << "find: key " << key << " ..." << std::endl;
|
||||
if( count > 0 ) {
|
||||
if( !v || !j.success() || ( v->size() != count ) ) {
|
||||
std::cout << " false negative - v: " << v << " success: " << j.success();
|
||||
if( v ) {
|
||||
std::cout << " expected count: " << count << " actual: " << v->size();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
return false;
|
||||
} else {
|
||||
// note - this doesn't verify that the right keys are returned, just the right number!
|
||||
jl2a::vector::const_iterator it = v->begin();
|
||||
std::cout << " correct number of values -";
|
||||
for( ; it != v->end(); it++ ) {
|
||||
std::cout << " " << *it;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
} else {
|
||||
if( v || j.success() ) {
|
||||
std::cout << " false positive - v: " << v << " success: " << j.success() << std::endl;
|
||||
return false;
|
||||
} else {
|
||||
std::cout << " not found, as expected." << std::endl;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
bool pass = true;
|
||||
jl2a jl;
|
||||
std::cout.setf( std::ios::boolalpha );
|
||||
// std::cout << "size of judyL2Array: " << sizeof( jl ) << std::endl;
|
||||
jl.insert( 5, 12 );
|
||||
jl.insert( 6, 2 );
|
||||
jl.insert( 7, 312 );
|
||||
jl.insert( 11, 412 );
|
||||
jl.insert( 7, 313 );
|
||||
jl2a::cpair kv = jl.atOrAfter( 4 );
|
||||
std::cout << "atOrAfter test ..." << std::endl;
|
||||
if( kv.value != 0 && jl.success() ) {
|
||||
std::cout << " key " << kv.key << " value " << kv.value->at( 0 ) << std::endl;
|
||||
} else {
|
||||
std::cout << " failed" << std::endl;
|
||||
pass = false;
|
||||
}
|
||||
|
||||
pass &= testFind( jl, 8, 0 );
|
||||
pass &= testFind( jl, 11, 1 );
|
||||
pass &= testFind( jl, 7, 2 );
|
||||
|
||||
jl.clear();
|
||||
|
||||
//TODO test all of judyL2Array
|
||||
if( pass ) {
|
||||
std::cout << "All tests passed." << std::endl;
|
||||
exit( EXIT_SUCCESS );
|
||||
} else {
|
||||
std::cout << "At least one test failed." << std::endl;
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "judyLArray.h"
|
||||
|
||||
int main() {
|
||||
std::cout.setf( std::ios::boolalpha );
|
||||
judyLArray< uint64_t, uint64_t > jl;
|
||||
std::cout << "size of judyLArray: " << sizeof( jl ) << std::endl;
|
||||
jl.insert( 5, 12 );
|
||||
jl.insert( 6, 2 );
|
||||
jl.insert( 7, 312 );
|
||||
jl.insert( 8, 412 );
|
||||
judyLArray< uint64_t, uint64_t >::pair kv = jl.atOrAfter( 4 );
|
||||
std::cout << "k " << kv.key << " v " << kv.value << std::endl;
|
||||
|
||||
long v = jl.find( 11 );
|
||||
if( v != 0 || jl.success() ) {
|
||||
std::cout << "find: false positive - v: " << v << " success: " << jl.success() << std::endl;
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
v = jl.find( 7 );
|
||||
if( v != 312 || !jl.success() ) {
|
||||
std::cout << "find: false negative - v: " << v << " success: " << jl.success() << std::endl;
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
jl.clear();
|
||||
|
||||
//TODO test all of judyLArray
|
||||
exit( EXIT_SUCCESS );
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "judyS2Array.h"
|
||||
|
||||
typedef judyS2Array< uint64_t > js2a;
|
||||
|
||||
bool testFind( js2a & j, const char * key, unsigned int count ) {
|
||||
js2a::cvector * v = j.find( key );
|
||||
std::cout << "find: key " << key << " ..." << std::endl;
|
||||
if( count > 0 ) {
|
||||
if( !v || !j.success() || ( v->size() != count ) ) {
|
||||
std::cout << " false negative - v: " << v << " success: " << j.success();
|
||||
if( v ) {
|
||||
std::cout << " expected count: " << count << " actual: " << v->size();
|
||||
}
|
||||
std::cout << std::endl;
|
||||
return false;
|
||||
} else {
|
||||
// note - this doesn't verify that the right keys are returned, just the right number!
|
||||
js2a::vector::const_iterator it = v->begin();
|
||||
std::cout << " correct number of values -";
|
||||
for( ; it != v->end(); it++ ) {
|
||||
std::cout << " " << *it;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
} else {
|
||||
if( v || j.success() ) {
|
||||
std::cout << " false positive - v: " << v << " success: " << j.success() << std::endl;
|
||||
return false;
|
||||
} else {
|
||||
std::cout << " not found, as expected." << std::endl;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
bool pass = true;
|
||||
std::cout.setf( std::ios::boolalpha );
|
||||
|
||||
js2a js( 255 );
|
||||
js.insert( "blah", 1234 );
|
||||
js.insert( "bah", 124 );
|
||||
js.insert( "blh", 123 );
|
||||
js.insert( "blh", 4123 );
|
||||
js.insert( "bla", 134 );
|
||||
js.insert( "bh", 234 );
|
||||
|
||||
js2a::cpair kv = js.atOrAfter( "ab" );
|
||||
std::cout << "atOrAfter test ..." << std::endl;
|
||||
if( kv.value != 0 && js.success() ) {
|
||||
std::cout << " key " << kv.key << " value " << kv.value->at( 0 ) << std::endl;
|
||||
} else {
|
||||
std::cout << " failed" << std::endl;
|
||||
pass = false;
|
||||
}
|
||||
|
||||
pass &= testFind( js, "sdafsd", 0 );
|
||||
pass &= testFind( js, "bah", 1 );
|
||||
pass &= testFind( js, "blh", 2 );
|
||||
|
||||
js.clear();
|
||||
|
||||
//TODO test all of judyS2Array
|
||||
if( pass ) {
|
||||
std::cout << "All tests passed." << std::endl;
|
||||
exit( EXIT_SUCCESS );
|
||||
} else {
|
||||
std::cout << "At least one test failed." << std::endl;
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "judySArray.h"
|
||||
|
||||
int main() {
|
||||
bool pass = true;
|
||||
std::cout.setf( std::ios::boolalpha );
|
||||
|
||||
judySArray< uint64_t > js( 255 );
|
||||
js.insert( "blah", 1234 );
|
||||
js.insert( "bah", 124 );
|
||||
js.insert( "blh", 123 );
|
||||
js.insert( "bla", 134 );
|
||||
js.insert( "bh", 234 );
|
||||
|
||||
|
||||
judySArray< uint64_t >::pair kv = js.atOrAfter( "ab" );
|
||||
//TODO if()...
|
||||
std::cout << "k " << kv.key << " v " << kv.value << std::endl;
|
||||
|
||||
long v = js.find( "sdafsd" );
|
||||
if( v != 0 || js.success() ) {
|
||||
std::cout << "find: false positive - v: " << v << " success: " << js.success() << std::endl;
|
||||
pass = false;
|
||||
}
|
||||
v = js.find( "bah" );
|
||||
if( v != 124 || !js.success() ) {
|
||||
std::cout << "find: false negative - v: " << v << " success: " << js.success() << std::endl;
|
||||
pass = false;
|
||||
}
|
||||
|
||||
|
||||
//TODO test all of judySArray
|
||||
if( pass ) {
|
||||
std::cout << "All tests passed." << std::endl;
|
||||
exit( EXIT_SUCCESS );
|
||||
} else {
|
||||
std::cout << "At least one test failed." << std::endl;
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
// Judy arrays 13 DEC 2012 (judy64n.c from http://code.google.com/p/judyarray/ )
|
||||
// This code is public domain.
|
||||
|
||||
// Author Karl Malbrain, malbrain AT yahoo.com
|
||||
// with assistance from Jan Weiss.
|
||||
// modifications (and any bugs) by Mark Pictor, mpictor at gmail
|
||||
|
||||
// Simplified judy arrays for strings and integers
|
||||
// Adapted from the ideas of Douglas Baskins of HP.
|
||||
|
||||
// Map a set of keys to corresponding memory cells (uints).
|
||||
// Each cell must be set to a non-zero value by the caller.
|
||||
|
||||
// STANDALONE is defined to compile into a string sorter.
|
||||
|
||||
// String mappings are denoted by calling judy_open with zero as
|
||||
// the second argument.
|
||||
|
||||
#ifndef STANDALONE
|
||||
# error must define STANDALONE while compiling this file and judy64.c
|
||||
#endif
|
||||
|
||||
#include "judy.h"
|
||||
#include "sort.h"
|
||||
|
||||
unsigned int MaxMem = 0;
|
||||
|
||||
// usage:
|
||||
// a.out [in-file] [out-file] [keysize] [recordlen] [keyoffset] [mergerecs]
|
||||
// where keysize is 10 to indicate pennysort files
|
||||
|
||||
// ASKITIS compilation:
|
||||
// g++ -O3 -fpermissive -fomit-frame-pointer -w -D STANDALONE -D ASKITIS -o judy64n judy64n.c
|
||||
// ./judy64n [input-file-to-build-judy] e.g. distinct_1 or skew1_1
|
||||
|
||||
// note: the judy array is an in-memory data structure. As such, make sure you
|
||||
// have enough memory to hold the entire input file + data structure, otherwise
|
||||
// you'll have to break the input file into smaller pieces and load them in
|
||||
// on-by-one.
|
||||
|
||||
// Also, the file to search judy is hardcoded to skew1_1.
|
||||
|
||||
int main( int argc, char ** argv ) {
|
||||
unsigned char buff[1024];
|
||||
JudySlot max = 0;
|
||||
JudySlot * cell;
|
||||
FILE * in, *out;
|
||||
void * judy;
|
||||
unsigned int len;
|
||||
unsigned int idx;
|
||||
#ifdef ASKITIS
|
||||
char * askitis;
|
||||
int prev, off;
|
||||
float insert_real_time = 0.0;
|
||||
float search_real_time = 0.0;
|
||||
int size;
|
||||
#if !defined(_WIN32)
|
||||
timer start, stop;
|
||||
#else
|
||||
time_t start[1], stop[1];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if( argc > 1 ) {
|
||||
in = fopen( argv[1], "rb" );
|
||||
} else {
|
||||
in = stdin;
|
||||
}
|
||||
|
||||
if( argc > 2 ) {
|
||||
out = fopen( argv[2], "wb" );
|
||||
} else {
|
||||
out = stdout;
|
||||
}
|
||||
|
||||
setvbuf( out, NULL, _IOFBF, 4096 * 1024 );
|
||||
|
||||
if( !in ) {
|
||||
fprintf( stderr, "unable to open input file\n" );
|
||||
}
|
||||
|
||||
if( !out ) {
|
||||
fprintf( stderr, "unable to open output file\n" );
|
||||
}
|
||||
|
||||
if( argc > 6 ) {
|
||||
PennyRecs = atoi( argv[6] );
|
||||
}
|
||||
|
||||
if( argc > 5 ) {
|
||||
PennyOff = atoi( argv[5] );
|
||||
}
|
||||
|
||||
if( argc > 4 ) {
|
||||
PennyLine = atoi( argv[4] );
|
||||
}
|
||||
|
||||
PennyMerge = ( unsigned long long )PennyLine * PennyRecs;
|
||||
|
||||
if( argc > 3 ) {
|
||||
PennyKey = atoi( argv[3] );
|
||||
sort( in, argv[2] );
|
||||
return merge( out, argv[2] );
|
||||
}
|
||||
|
||||
#ifdef ASKITIS
|
||||
judy = judy_open( 1024, 0 );
|
||||
|
||||
// build judy array
|
||||
size = lseek( fileno( in ), 0L, 2 );
|
||||
askitis = malloc( size );
|
||||
lseek( fileno( in ), 0L, 0 );
|
||||
read( fileno( in ), askitis, size );
|
||||
prev = 0;
|
||||
// naskitis.com:
|
||||
// Start the timer.
|
||||
|
||||
#if !defined(_WIN32)
|
||||
gettimeofday( &start, NULL );
|
||||
#else
|
||||
time( start );
|
||||
#endif
|
||||
|
||||
for( off = 0; off < size; off++ )
|
||||
if( askitis[off] == '\n' ) {
|
||||
*( judy_cell( judy, askitis + prev, off - prev ) ) += 1; // count instances of string
|
||||
prev = off + 1;
|
||||
}
|
||||
// naskitis.com:
|
||||
// Stop the timer and do some math to compute the time required to insert the strings into the judy array.
|
||||
|
||||
#if !defined(_WIN32)
|
||||
gettimeofday( &stop, NULL );
|
||||
|
||||
insert_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001 * ( stop.tv_usec - start.tv_usec );
|
||||
insert_real_time = insert_real_time / 1000.0;
|
||||
#else
|
||||
time( stop );
|
||||
insert_real_time = *stop - *start;
|
||||
#endif
|
||||
|
||||
// naskitis.com:
|
||||
// Free the input buffer used to store the first file. We must do this before we get the process size below.
|
||||
free( askitis );
|
||||
fprintf( stderr, "JudyArray@Karl_Malbrain\nDASKITIS option enabled\n-------------------------------\n%-20s %.2f MB\n%-20s %.2f sec\n",
|
||||
"Judy Array size:", MaxMem / 1000000., "Time to insert:", insert_real_time );
|
||||
fprintf( stderr, "%-20s %d\n", "Words:", Words );
|
||||
fprintf( stderr, "%-20s %d\n", "Inserts:", Inserts );
|
||||
fprintf( stderr, "%-20s %d\n", "Found:", Found );
|
||||
|
||||
Words = 0;
|
||||
Inserts = 0;
|
||||
Found = 0;
|
||||
|
||||
// search judy array
|
||||
if( in = freopen( "skew1_1", "rb", in ) ) {
|
||||
size = lseek( fileno( in ), 0L, 2 );
|
||||
} else {
|
||||
exit( 0 );
|
||||
}
|
||||
askitis = malloc( size );
|
||||
lseek( fileno( in ), 0L, 0 );
|
||||
read( fileno( in ), askitis, size );
|
||||
prev = 0;
|
||||
|
||||
#if !defined(_WIN32)
|
||||
gettimeofday( &start, NULL );
|
||||
#else
|
||||
time( start );
|
||||
#endif
|
||||
|
||||
for( off = 0; off < size; off++ )
|
||||
if( askitis[off] == '\n' ) {
|
||||
*judy_cell( judy, askitis + prev, off - prev ) += 1;
|
||||
prev = off + 1;
|
||||
}
|
||||
// naskitis.com:
|
||||
// Stop the timer and do some math to compute the time required to search the judy array.
|
||||
|
||||
#if !defined(_WIN32)
|
||||
gettimeofday( &stop, NULL );
|
||||
search_real_time = 1000.0 * ( stop.tv_sec - start.tv_sec ) + 0.001
|
||||
* ( stop.tv_usec - start.tv_usec );
|
||||
search_real_time = search_real_time / 1000.0;
|
||||
#else
|
||||
time( stop );
|
||||
search_real_time = *stop - *start;
|
||||
#endif
|
||||
|
||||
// naskitis.com:
|
||||
// To do: report a count on the number of strings found.
|
||||
|
||||
fprintf( stderr, "\n%-20s %.2f MB\n%-20s %.2f sec\n",
|
||||
"Judy Array size:", MaxMem / 1000000., "Time to search:", search_real_time );
|
||||
fprintf( stderr, "%-20s %d\n", "Words:", Words );
|
||||
fprintf( stderr, "%-20s %d\n", "Inserts:", Inserts );
|
||||
fprintf( stderr, "%-20s %d\n", "Found:", Found );
|
||||
exit( 0 );
|
||||
#endif
|
||||
|
||||
judy = judy_open( 1024, 0 );
|
||||
|
||||
while( fgets( ( char * )buff, sizeof( buff ), in ) ) {
|
||||
if( len = strlen( ( const char * )buff ) ) {
|
||||
buff[--len] = 0; // remove LF
|
||||
}
|
||||
*( judy_cell( judy, buff, len ) ) += 1; // count instances of string
|
||||
max++;
|
||||
}
|
||||
|
||||
fprintf( stderr, "%" PRIuint " memory used\n", MaxMem );
|
||||
|
||||
cell = judy_strt( judy, NULL, 0 );
|
||||
|
||||
if( cell ) do {
|
||||
len = judy_key( judy, buff, sizeof( buff ) );
|
||||
for( idx = 0; idx < *cell; idx++ ) { // spit out duplicates
|
||||
fwrite( buff, len, 1, out );
|
||||
fputc( '\n', out );
|
||||
}
|
||||
} while( cell = judy_nxt( judy ) );
|
||||
|
||||
#if 0
|
||||
// test deletion all the way to an empty tree
|
||||
|
||||
if( cell = judy_prv( judy ) )
|
||||
do {
|
||||
max -= *cell;
|
||||
} while( cell = judy_del( judy ) );
|
||||
|
||||
assert( max == 0 );
|
||||
#endif
|
||||
judy_close( judy );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
// Judy arrays 13 DEC 2012 (judy64n.c from http://code.google.com/p/judyarray/ )
|
||||
// This code is public domain.
|
||||
|
||||
// Author Karl Malbrain, malbrain AT yahoo.com
|
||||
// with assistance from Jan Weiss.
|
||||
// modifications (and any bugs) by Mark Pictor, mpictor at gmail
|
||||
|
||||
// Simplified judy arrays for strings and integers
|
||||
// Adapted from the ideas of Douglas Baskins of HP.
|
||||
|
||||
// Map a set of keys to corresponding memory cells (uints).
|
||||
// Each cell must be set to a non-zero value by the caller.
|
||||
|
||||
// STANDALONE is defined to compile into a string sorter.
|
||||
|
||||
// String mappings are denoted by calling judy_open with zero as
|
||||
// the second argument. Integer mappings are denoted by calling
|
||||
// judy_open with the Integer depth of the Judy Trie as the second
|
||||
// argument.
|
||||
|
||||
#include "judy.h"
|
||||
#include "sort.h"
|
||||
|
||||
// memory map input file and sort
|
||||
|
||||
// define pennysort parameters
|
||||
unsigned int PennyRecs = ( 4096 * 400 ); // records to sort to temp files
|
||||
unsigned int PennyLine = 100; // length of input record
|
||||
unsigned int PennyKey = 10; // length of input key
|
||||
unsigned int PennyOff = 0; // key offset in input record
|
||||
|
||||
unsigned long long PennyMerge; // PennyRecs * PennyLine = file map length
|
||||
unsigned int PennyPasses; // number of intermediate files created
|
||||
unsigned int PennySortTime; // cpu time to run sort
|
||||
unsigned int PennyMergeTime; // cpu time to run merge
|
||||
|
||||
void sort( FILE * infile, char * outname ) {
|
||||
unsigned long long size, off, offset, part;
|
||||
int ifd = fileno( infile );
|
||||
char filename[512];
|
||||
PennySort * line;
|
||||
JudySlot * cell;
|
||||
unsigned char * inbuff;
|
||||
void * judy;
|
||||
FILE * out;
|
||||
#if defined(_WIN32)
|
||||
HANDLE hndl, fm;
|
||||
DWORD hiword;
|
||||
FILETIME dummy[1];
|
||||
FILETIME user[1];
|
||||
#else
|
||||
struct tms buff[1];
|
||||
#endif
|
||||
time_t start = time( NULL );
|
||||
|
||||
if( PennyOff + PennyKey > PennyLine ) {
|
||||
fprintf( stderr, "Key Offset + Key Length > Record Length\n" ), exit( 1 );
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
PennyPasses = 0;
|
||||
|
||||
#if defined(_WIN32)
|
||||
hndl = ( HANDLE )_get_osfhandle( ifd );
|
||||
size = GetFileSize( hndl, &hiword );
|
||||
fm = CreateFileMapping( hndl, NULL, PAGE_READONLY, hiword, ( DWORD )size, NULL );
|
||||
if( !fm ) {
|
||||
fprintf( stderr, "CreateFileMapping error %d\n", GetLastError() ), exit( 1 );
|
||||
}
|
||||
size |= ( unsigned long long )hiword << 32;
|
||||
#else
|
||||
size = lseek( ifd, 0L, 2 );
|
||||
#endif
|
||||
|
||||
while( offset < size ) {
|
||||
#if defined(_WIN32)
|
||||
part = offset + PennyMerge > size ? size - offset : PennyMerge;
|
||||
inbuff = MapViewOfFile( fm, FILE_MAP_READ, offset >> 32, offset, part );
|
||||
if( !inbuff ) {
|
||||
fprintf( stderr, "MapViewOfFile error %d\n", GetLastError() ), exit( 1 );
|
||||
}
|
||||
#else
|
||||
inbuff = mmap( NULL, PennyMerge, PROT_READ, MAP_SHARED, ifd, offset );
|
||||
|
||||
if( inbuff == MAP_FAILED ) {
|
||||
fprintf( stderr, "mmap error %d\n", errno ), exit( 1 );
|
||||
}
|
||||
|
||||
if( madvise( inbuff, PennyMerge, MADV_WILLNEED | MADV_SEQUENTIAL ) < 0 ) {
|
||||
fprintf( stderr, "madvise error %d\n", errno );
|
||||
}
|
||||
#endif
|
||||
judy = judy_open( PennyKey, 0 );
|
||||
|
||||
off = 0;
|
||||
|
||||
// build judy array from mapped input chunk
|
||||
|
||||
while( offset + off < size && off < PennyMerge ) {
|
||||
line = judy_data( judy, sizeof( PennySort ) );
|
||||
cell = judy_cell( judy, inbuff + off + PennyOff, PennyKey );
|
||||
line->next = *( void ** )cell;
|
||||
line->buff = inbuff + off;
|
||||
|
||||
*( PennySort ** )cell = line;
|
||||
off += PennyLine;
|
||||
}
|
||||
|
||||
sprintf( filename, "%s.%d", outname, PennyPasses );
|
||||
out = fopen( filename, "wb" );
|
||||
setvbuf( out, NULL, _IOFBF, 4096 * 1024 );
|
||||
|
||||
#ifndef _WIN32
|
||||
if( madvise( inbuff, PennyMerge, MADV_WILLNEED | MADV_RANDOM ) < 0 ) {
|
||||
fprintf( stderr, "madvise error %d\n", errno );
|
||||
}
|
||||
#endif
|
||||
|
||||
// write judy array in sorted order to temporary file
|
||||
|
||||
cell = judy_strt( judy, NULL, 0 );
|
||||
|
||||
if( cell ) do {
|
||||
line = *( PennySort ** )cell;
|
||||
do {
|
||||
fwrite( line->buff, PennyLine, 1, out );
|
||||
} while( line = line->next );
|
||||
} while( cell = judy_nxt( judy ) );
|
||||
|
||||
#if defined(_WIN32)
|
||||
UnmapViewOfFile( inbuff );
|
||||
#else
|
||||
munmap( inbuff, PennyMerge );
|
||||
#endif
|
||||
judy_close( judy );
|
||||
offset += off;
|
||||
fflush( out );
|
||||
fclose( out );
|
||||
PennyPasses++;
|
||||
}
|
||||
fprintf( stderr, "End Sort %llu secs", ( unsigned long long ) time( NULL ) - start );
|
||||
#if defined(_WIN32)
|
||||
CloseHandle( fm );
|
||||
GetProcessTimes( GetCurrentProcess(), dummy, dummy, dummy, user );
|
||||
PennySortTime = *( unsigned long long * )user / 10000000;
|
||||
#else
|
||||
times( buff );
|
||||
PennySortTime = buff->tms_utime / 100;
|
||||
#endif
|
||||
fprintf( stderr, " Cpu %d\n", PennySortTime );
|
||||
}
|
||||
|
||||
int merge( FILE * out, char * outname ) {
|
||||
time_t start = time( NULL );
|
||||
char filename[512];
|
||||
JudySlot * cell;
|
||||
unsigned int nxt, idx;
|
||||
unsigned char ** line;
|
||||
unsigned int * next;
|
||||
void * judy;
|
||||
FILE ** in;
|
||||
|
||||
next = calloc( PennyPasses + 1, sizeof( unsigned int ) );
|
||||
line = calloc( PennyPasses, sizeof( void * ) );
|
||||
in = calloc( PennyPasses, sizeof( void * ) );
|
||||
|
||||
judy = judy_open( PennyKey, 0 );
|
||||
|
||||
// initialize merge with one record from each temp file
|
||||
|
||||
for( idx = 0; idx < PennyPasses; idx++ ) {
|
||||
sprintf( filename, "%s.%d", outname, idx );
|
||||
in[idx] = fopen( filename, "rb" );
|
||||
line[idx] = malloc( PennyLine );
|
||||
setvbuf( in[idx], NULL, _IOFBF, 4096 * 1024 );
|
||||
fread( line[idx], PennyLine, 1, in[idx] );
|
||||
cell = judy_cell( judy, line[idx] + PennyOff, PennyKey );
|
||||
next[idx + 1] = *( unsigned int * )cell;
|
||||
*cell = idx + 1;
|
||||
}
|
||||
|
||||
// output records, replacing smallest each time
|
||||
|
||||
while( cell = judy_strt( judy, NULL, 0 ) ) {
|
||||
nxt = *( unsigned int * )cell;
|
||||
judy_del( judy );
|
||||
|
||||
// process duplicates
|
||||
|
||||
while( idx = nxt ) {
|
||||
nxt = next[idx--];
|
||||
fwrite( line[idx], PennyLine, 1, out );
|
||||
|
||||
if( fread( line[idx], PennyLine, 1, in[idx] ) ) {
|
||||
cell = judy_cell( judy, line[idx] + PennyOff, PennyKey );
|
||||
next[idx + 1] = *( unsigned int * )cell;
|
||||
*cell = idx + 1;
|
||||
} else {
|
||||
next[idx + 1] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( idx = 0; idx < PennyPasses; idx++ ) {
|
||||
fclose( in[idx] );
|
||||
free( line[idx] );
|
||||
}
|
||||
|
||||
free( line );
|
||||
free( next );
|
||||
free( in );
|
||||
|
||||
fprintf( stderr, "End Merge %llu secs", ( unsigned long long ) time( NULL ) - start );
|
||||
#ifdef _WIN32
|
||||
{
|
||||
FILETIME dummy[1];
|
||||
FILETIME user[1];
|
||||
GetProcessTimes( GetCurrentProcess(), dummy, dummy, dummy, user );
|
||||
PennyMergeTime = *( unsigned long long * )user / 10000000;
|
||||
}
|
||||
#else
|
||||
{
|
||||
struct tms buff[1];
|
||||
times( buff );
|
||||
PennyMergeTime = buff->tms_utime / 100;
|
||||
}
|
||||
#endif
|
||||
fprintf( stderr, " Cpu %d\n", PennyMergeTime - PennySortTime );
|
||||
judy_close( judy );
|
||||
fflush( out );
|
||||
fclose( out );
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef SORT_H
|
||||
#define SORT_H
|
||||
|
||||
// Judy arrays 13 DEC 2012 (judy64n.c from http://code.google.com/p/judyarray/ )
|
||||
// This code is public domain.
|
||||
|
||||
// Author Karl Malbrain, malbrain AT yahoo.com
|
||||
// with assistance from Jan Weiss.
|
||||
// modifications (and any bugs) by Mark Pictor, mpictor at gmail
|
||||
|
||||
// Simplified judy arrays for strings and integers
|
||||
// Adapted from the ideas of Douglas Baskins of HP.
|
||||
|
||||
// Map a set of keys to corresponding memory cells (uints).
|
||||
// Each cell must be set to a non-zero value by the caller.
|
||||
|
||||
// STANDALONE is defined to compile into a string sorter.
|
||||
|
||||
// String mappings are denoted by calling judy_open with zero as
|
||||
// the second argument. Integer mappings are denoted by calling
|
||||
// judy_open with the Integer depth of the Judy Trie as the second
|
||||
// argument.
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "judy.h"
|
||||
|
||||
#ifdef linux
|
||||
# include <fcntl.h>
|
||||
# include <unistd.h>
|
||||
# include <errno.h>
|
||||
# include <sys/mman.h>
|
||||
# include <sys/times.h>
|
||||
#else
|
||||
# include <windows.h>
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#define PRIuint "u"
|
||||
|
||||
|
||||
//these are initialized in penny.c
|
||||
extern unsigned int PennyRecs;
|
||||
extern unsigned int PennyLine;
|
||||
extern unsigned int PennyKey;
|
||||
extern unsigned int PennyOff;
|
||||
extern unsigned long long PennyMerge;
|
||||
|
||||
typedef struct {
|
||||
void * buff; // record pointer in input file map
|
||||
void * next; // duplicate chain
|
||||
} PennySort;
|
||||
|
||||
#endif //SORT_H
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#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,6 +1,7 @@
|
||||
/// \file sc_benchmark.cc memory info, timers, etc for benchmarking
|
||||
|
||||
#include "./sc_benchmark.h"
|
||||
#include "sc_benchmark.h"
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@@ -2,11 +2,14 @@
|
||||
#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
|
||||
|
||||
@@ -20,7 +23,7 @@ extern "C" {
|
||||
*
|
||||
* not yet implemented for OSX or Windows.
|
||||
*/
|
||||
benchVals getMemAndTime( );
|
||||
SC_BASE_EXPORT benchVals getMemAndTime( );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@@ -36,7 +39,7 @@ extern "C" {
|
||||
* depends on getMemAndTime() above - may not work on all platforms.
|
||||
*/
|
||||
|
||||
class benchmark {
|
||||
class SC_BASE_EXPORT benchmark {
|
||||
protected:
|
||||
benchVals initialVals, laterVals;
|
||||
#ifdef _MSC_VER
|
||||
@@ -0,0 +1,214 @@
|
||||
/****** 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;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/** \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 */
|
||||
@@ -0,0 +1,405 @@
|
||||
|
||||
#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 */
|
||||
@@ -0,0 +1,79 @@
|
||||
#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 */
|
||||
@@ -0,0 +1,32 @@
|
||||
#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;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef SC_MKDIR
|
||||
#define SC_MKDIR
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
/** cross-platform mkdir() */
|
||||
SC_BASE_EXPORT int sc_mkdir( const char * path );
|
||||
|
||||
/** create a dir 'path' if 'path' doesn't exist
|
||||
* \return -1 if error, 0 if created, 1 if dir existed already
|
||||
* if it returns -1, check errno
|
||||
*/
|
||||
SC_BASE_EXPORT int mkDirIfNone( const char * path );
|
||||
|
||||
#endif /* SC_MKDIR */
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef __SC_STDIO_H
|
||||
#define __SC_STDIO_H
|
||||
|
||||
/*
|
||||
* https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
|
||||
* (NOTE: MSVC defines va_list as a char*, so this should be safe)
|
||||
*/
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
||||
#include <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 */
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef SC_STRTOULL_H
|
||||
#define SC_STRTOULL_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# define strtoull _strtoui64
|
||||
# define ULLONG_MAX _UI64_MAX
|
||||
#endif
|
||||
|
||||
#endif /* SC_STRTOULL_H */
|
||||
@@ -1,7 +1,8 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "trace_fprintf.h"
|
||||
#include "sc_trace_fprintf.h"
|
||||
|
||||
void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... ) {
|
||||
va_list args;
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef SC_TRACE_FPRINTF_H
|
||||
#define SC_TRACE_FPRINTF_H
|
||||
|
||||
/** \file trace_fprintf.h
|
||||
/** \file sc_trace_fprintf.h
|
||||
* Used to track the source file and line where generated code is printed from
|
||||
* When enabled, comments are printed into the generated files for every 'fprintf':
|
||||
* / * source: scl/src/exp2cxx/selects.c:1375 * /
|
||||
@@ -20,7 +20,7 @@ extern "C" {
|
||||
/** Used to find where generated c++ originates from in exp2cxx.
|
||||
* To enable, configure with 'cmake .. -DSC_TRACE_FPRINTF=ON'
|
||||
*/
|
||||
void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... );
|
||||
SC_BASE_EXPORT void trace_fprintf( char const * sourcefile, int line, FILE * file, const char * format, ... );
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,4 +1,5 @@
|
||||
set(DAI_SRCS
|
||||
|
||||
set(LIBSTEPDAI_SRCS
|
||||
sdaiApplication_instance_set.cc
|
||||
sdaiBinary.cc
|
||||
sdaiDaObject.cc
|
||||
@@ -12,24 +13,43 @@ set(DAI_SRCS
|
||||
sdaiString.cc
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/include/stepcode
|
||||
SET(SC_CLDAI_HDRS
|
||||
sdaiApplication_instance_set.h
|
||||
sdaiBinary.h
|
||||
sdaiDaObject.h
|
||||
sdaiEntity_extent.h
|
||||
sdaiEntity_extent_set.h
|
||||
sdaiEnum.h
|
||||
sdaiModel_contents.h
|
||||
sdaiModel_contents_list.h
|
||||
sdaiObject.h
|
||||
sdaiSession_instance.h
|
||||
sdaiString.h
|
||||
)
|
||||
|
||||
set(_libdeps steputils)
|
||||
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)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
SC_ADDLIB(stepdai SHARED SOURCES ${DAI_SRCS} LINK_LIBRARIES ${_libdeps})
|
||||
SC_ADDLIB(stepdai SHARED SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES ${_libdeps})
|
||||
if(WIN32)
|
||||
target_compile_definitions(stepdai PRIVATE SC_DAI_DLL_EXPORTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_STATIC_LIBS)
|
||||
SC_ADDLIB(stepdai-static STATIC SOURCES ${DAI_SRCS} LINK_LIBRARIES $<JOIN:${_libdeps},-static >-static)
|
||||
SC_ADDLIB(stepdai-static STATIC SOURCES ${LIBSTEPDAI_SRCS} LINK_LIBRARIES $<JOIN:${_libdeps},-static >-static)
|
||||
endif()
|
||||
|
||||
install(FILES ${SC_CLDAI_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/cldai)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
* UArray implementation.
|
||||
*/
|
||||
|
||||
//#include "cldai/sdaiApplication_instance_set.h"
|
||||
#include "clstepcore/sdai.h"
|
||||
//#include <sdaiApplication_instance_set.h>
|
||||
#include <sdai.h>
|
||||
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
#include "clstepcore/sdaiApplication_instance.h"
|
||||
#include "sdaiApplication_instance.h"
|
||||
|
||||
// to help ObjectCenter
|
||||
#ifndef HAVE_MEMMOVE
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
*/
|
||||
|
||||
#include <sstream>
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_Binary::SDAI_Binary( const char * str, int max ) {
|
||||
content = std::string( str, max );
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
// to help ObjectCenter
|
||||
#ifndef HAVE_MEMMOVE
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef SDAIDAOBJECT_H
|
||||
#define SDAIDAOBJECT_H 1
|
||||
|
||||
#include "cldai/sdaiObject.h"
|
||||
#include "cldai/sdaiString.h"
|
||||
#include "cldai/sdaiEnum.h"
|
||||
#include <sdaiObject.h>
|
||||
#include <sdaiString.h>
|
||||
#include <sdaiEnum.h>
|
||||
|
||||
#include <sc_export.h>
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
//#include <EntityExtent.h>
|
||||
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_Entity_extent::SDAI_Entity_extent( )
|
||||
: _definition( 0 ), _definition_name( 0 ), _owned_by( 0 ) {
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
/*
|
||||
#include <EntityExtent.h>
|
||||
@@ -50,7 +51,7 @@ SDAI_Entity_extent__set::SDAI_Entity_extent__set( int defaultSize ) {
|
||||
}
|
||||
|
||||
SDAI_Entity_extent__set::~SDAI_Entity_extent__set() {
|
||||
delete[] _buf;
|
||||
delete _buf;
|
||||
}
|
||||
|
||||
void SDAI_Entity_extent__set::Check( int index ) {
|
||||
@@ -61,7 +62,7 @@ void SDAI_Entity_extent__set::Check( int index ) {
|
||||
_bufsize = ( index + 1 ) * 2;
|
||||
newbuf = new SDAI_Entity_extent_ptr[_bufsize];
|
||||
memmove( newbuf, _buf, _count * sizeof( SDAI_Entity_extent_ptr ) );
|
||||
delete[] _buf;
|
||||
delete _buf;
|
||||
_buf = newbuf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
/*
|
||||
* NIST STEP Core Class Library
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
///////// SDAI_Model_contents_instances
|
||||
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
/*
|
||||
* UArray implementation.
|
||||
*/
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
// to help ObjectCenter
|
||||
#ifndef HAVE_MEMMOVE
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_sdaiObject::SDAI_sdaiObject() {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_Session_instance::SDAI_Session_instance() {
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#define SESSION_INSTANCE_H 1
|
||||
|
||||
#include <sc_export.h>
|
||||
//#include "clstepcore/sdai.h"
|
||||
//#include <sdai.h>
|
||||
|
||||
class SC_DAI_EXPORT SDAI_Session_instance : public SDAI_sdaiObject {
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
* and is not subject to copyright.
|
||||
*/
|
||||
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
#include <sstream>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
SDAI_String::SDAI_String( const char * str, size_t max ) {
|
||||
if( !str ) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
set(EDITOR_SRCS
|
||||
|
||||
set(LIBSTEPEDITOR_SRCS
|
||||
STEPfile.cc
|
||||
STEPfile.inline.cc
|
||||
cmdmgr.cc
|
||||
@@ -8,22 +9,38 @@ set(EDITOR_SRCS
|
||||
SdaiSchemaInit.cc
|
||||
)
|
||||
|
||||
SET(SC_CLEDITOR_HDRS
|
||||
STEPfile.h
|
||||
cmdmgr.h
|
||||
editordefines.h
|
||||
SdaiHeaderSchema.h
|
||||
SdaiHeaderSchemaClasses.h
|
||||
SdaiSchemaInit.h
|
||||
seeinfodefault.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/include/stepcode
|
||||
${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 ${EDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils)
|
||||
SC_ADDLIB(stepeditor SHARED SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore stepdai steputils base)
|
||||
if(WIN32)
|
||||
target_compile_definitions(stepeditor PRIVATE SC_EDITOR_DLL_EXPORTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_STATIC_LIBS)
|
||||
SC_ADDLIB(stepeditor-static STATIC SOURCES ${EDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static)
|
||||
SC_ADDLIB(stepeditor-static STATIC SOURCES ${LIBSTEPEDITOR_SRCS} LINK_LIBRARIES stepcore-static stepdai-static steputils-static base-static)
|
||||
endif()
|
||||
|
||||
install(FILES ${SC_CLEDITOR_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/cleditor)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
|
||||
+16
-33
@@ -24,15 +24,17 @@
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "cleditor/STEPfile.h"
|
||||
#include "clstepcore/sdai.h"
|
||||
#include "clstepcore/STEPcomplex.h"
|
||||
#include "clstepcore/STEPattribute.h"
|
||||
#include "cleditor/SdaiHeaderSchema.h"
|
||||
#include <STEPfile.h>
|
||||
#include <sdai.h>
|
||||
#include <STEPcomplex.h>
|
||||
#include <STEPattribute.h>
|
||||
#include <SdaiHeaderSchema.h>
|
||||
|
||||
// STEPundefined contains
|
||||
// void PushPastString (istream& in, std::string &s, ErrorDescriptor *err)
|
||||
#include "clstepcore/STEPundefined.h"
|
||||
#include <STEPundefined.h>
|
||||
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
/**
|
||||
* \returns The new file name for the class.
|
||||
@@ -115,7 +117,7 @@ Severity STEPfile::ReadHeader( istream & in ) {
|
||||
int fileid;
|
||||
std::string keywd;
|
||||
char c = '\0';
|
||||
char buf [BUFSIZ+1];
|
||||
char buf [BUFSIZ];
|
||||
|
||||
std::string strbuf;
|
||||
|
||||
@@ -440,7 +442,7 @@ int STEPfile::ReadData1( istream & in ) {
|
||||
|
||||
char c;
|
||||
int instance_count = 0;
|
||||
char buf[BUFSIZ+1];
|
||||
char buf[BUFSIZ];
|
||||
buf[0] = '\0';
|
||||
std::string tmpbuf;
|
||||
|
||||
@@ -563,7 +565,7 @@ int STEPfile::ReadData2( istream & in, bool useTechCor ) {
|
||||
_warningCount = 0; // reset error count
|
||||
|
||||
char c;
|
||||
char buf[BUFSIZ+1];
|
||||
char buf[BUFSIZ];
|
||||
buf[0] = '\0';
|
||||
std::string tmpbuf;
|
||||
|
||||
@@ -728,7 +730,7 @@ int STEPfile::FindDataSection( istream & in ) {
|
||||
}
|
||||
|
||||
int STEPfile::FindHeaderSection( istream & in ) {
|
||||
char buf[BUFSIZ+1];
|
||||
char buf[BUFSIZ];
|
||||
char * b = buf;
|
||||
|
||||
*b = '\0';
|
||||
@@ -849,8 +851,6 @@ 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,8 +879,6 @@ 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;
|
||||
@@ -889,10 +887,6 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou
|
||||
SkipInstance( in, tmpbuf );
|
||||
|
||||
ReadTokenSeparator( in );
|
||||
|
||||
if (scopelist)
|
||||
delete[] scopelist;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@@ -1156,7 +1150,7 @@ SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out,
|
||||
Severity sev = SEVERITY_NULL;
|
||||
|
||||
std::string tmpbuf;
|
||||
char errbuf[BUFSIZ+1];
|
||||
char errbuf[BUFSIZ];
|
||||
errbuf[0] = '\0';
|
||||
std::string currSch;
|
||||
std::string objnm;
|
||||
@@ -1537,11 +1531,9 @@ 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
|
||||
@@ -1561,9 +1553,6 @@ void STEPfile::WriteHeaderInstanceFileName( ostream & out ) {
|
||||
|
||||
//output the values to the file
|
||||
WriteHeaderInstance( se, out );
|
||||
|
||||
if (del_se)
|
||||
delete se;
|
||||
}
|
||||
|
||||
void STEPfile::WriteHeaderInstanceFileDescription( ostream & out ) {
|
||||
@@ -1574,11 +1563,8 @@ 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 ) {
|
||||
@@ -1589,11 +1575,8 @@ 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 ) {
|
||||
@@ -1620,7 +1603,7 @@ void STEPfile::WriteValuePairsData( ostream & out, int writeComments, int mixedC
|
||||
|
||||
Severity STEPfile::AppendFile( istream * in, bool useTechCor ) {
|
||||
Severity rval = SEVERITY_NULL;
|
||||
char errbuf[BUFSIZ+1];
|
||||
char errbuf[BUFSIZ];
|
||||
|
||||
SetFileIdIncrement();
|
||||
int total_insts = 0, valid_insts = 0;
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
|
||||
#include <sc_export.h>
|
||||
#include <string>
|
||||
#include "clstepcore/instmgr.h"
|
||||
#include "clstepcore/Registry.h"
|
||||
#include <instmgr.h>
|
||||
#include <Registry.h>
|
||||
#include <fstream>
|
||||
#include "clutils/dirobj.h"
|
||||
#include "clutils/errordesc.h"
|
||||
#include <dirobj.h>
|
||||
#include <errordesc.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "clstepcore/read_func.h"
|
||||
#include <read_func.h>
|
||||
|
||||
//error reporting level
|
||||
#define READ_COMPLETE 10
|
||||
@@ -11,12 +11,13 @@
|
||||
* and is not subject to copyright.
|
||||
*/
|
||||
|
||||
#include "cleditor/STEPfile.h"
|
||||
#include "cleditor/SdaiHeaderSchema.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include <STEPfile.h>
|
||||
#include <SdaiHeaderSchema.h>
|
||||
#include <STEPaggregate.h>
|
||||
#include <cmath>
|
||||
|
||||
#include <cstring>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
extern void HeaderSchemaInit( Registry & reg );
|
||||
|
||||
@@ -178,7 +179,7 @@ istream * STEPfile::OpenInputFile( const std::string filename ) {
|
||||
return( 0 );
|
||||
} else {
|
||||
if( SetFileName( filename ).empty() && ( filename.compare( "-" ) != 0 ) ) {
|
||||
char msg[BUFSIZ+1];
|
||||
char msg[BUFSIZ];
|
||||
sprintf( msg, "Unable to find file for input: \'%s\'. File not read.\n", filename.c_str() );
|
||||
_error.AppendToUserMsg( msg );
|
||||
_error.GreaterSeverity( SEVERITY_INPUT_ERROR );
|
||||
@@ -195,7 +196,7 @@ istream * STEPfile::OpenInputFile( const std::string filename ) {
|
||||
}
|
||||
|
||||
if( !in || !( in -> good() ) ) {
|
||||
char msg[BUFSIZ+1];
|
||||
char msg[BUFSIZ];
|
||||
sprintf( msg, "Unable to open file for input: \'%s\'. File not read.\n", filename.c_str() );
|
||||
_error.AppendToUserMsg( msg );
|
||||
_error.GreaterSeverity( SEVERITY_INPUT_ERROR );
|
||||
@@ -230,7 +231,7 @@ ofstream * STEPfile::OpenOutputFile( std::string filename ) {
|
||||
}
|
||||
} else {
|
||||
if( SetFileName( filename ).empty() ) {
|
||||
char msg[BUFSIZ+1];
|
||||
char msg[BUFSIZ];
|
||||
sprintf( msg, "can't find file: %s\nFile not written.\n", filename.c_str() );
|
||||
_error.AppendToUserMsg( msg );
|
||||
_error.GreaterSeverity( SEVERITY_INPUT_ERROR );
|
||||
|
||||
@@ -10,9 +10,10 @@ extern ofstream * logStream;
|
||||
#define SCLLOGFILE "scl.log"
|
||||
#endif
|
||||
|
||||
#include "clstepcore/ExpDict.h"
|
||||
#include "clstepcore/STEPattribute.h"
|
||||
#include "cleditor/SdaiHeaderSchema.h"
|
||||
#include <ExpDict.h>
|
||||
#include <STEPattribute.h>
|
||||
#include <SdaiHeaderSchema.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
Schema * s_header_section_schema = 0;
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
// regenerate it.
|
||||
|
||||
#include <sc_export.h>
|
||||
#include "clstepcore/sdai.h"
|
||||
#include "clstepcore/Registry.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include "cleditor/SdaiHeaderSchemaClasses.h"
|
||||
#include "cleditor/SdaiSchemaInit.h"
|
||||
#include <sdai.h>
|
||||
#include <Registry.h>
|
||||
#include <STEPaggregate.h>
|
||||
#include <SdaiHeaderSchemaClasses.h>
|
||||
#include <SdaiSchemaInit.h>
|
||||
|
||||
///////// ENTITY section_language
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
// it since your modifications will be lost if exp2cxx is used to
|
||||
// regenerate it.
|
||||
|
||||
#include "cleditor/SdaiHeaderSchema.h"
|
||||
#include <SdaiHeaderSchema.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
void HeaderInitSchemasAndEnts( Registry & reg ) {
|
||||
Uniqueness_rule_ptr ur;
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
// it since your modifications will be lost if exp2cxx is used to
|
||||
// regenerate it.
|
||||
|
||||
#include "clstepcore/Registry.h"
|
||||
#include "clstepcore/ExpDict.h"
|
||||
#include "clstepcore/STEPattribute.h"
|
||||
#include "cleditor/SdaiHeaderSchema.h"
|
||||
#include <Registry.h>
|
||||
#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 );
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
// it since your modifications will be lost if exp2cxx is used to
|
||||
// regenerate it.
|
||||
|
||||
#include "cleditor/SdaiSchemaInit.h"
|
||||
#include <SdaiSchemaInit.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
void HeaderSchemaInit( Registry & reg ) {
|
||||
HeaderInitSchemasAndEnts( reg );
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
#endif
|
||||
|
||||
#include <sc_export.h>
|
||||
#include "clstepcore/sdai.h"
|
||||
#include "clstepcore/Registry.h"
|
||||
#include "clstepcore/STEPaggregate.h"
|
||||
#include "clstepcore/STEPundefined.h"
|
||||
#include "clstepcore/ExpDict.h"
|
||||
#include "clstepcore/STEPattribute.h"
|
||||
#include "clstepcore/complexSupport.h"
|
||||
#include <sdai.h>
|
||||
#include <Registry.h>
|
||||
#include <STEPaggregate.h>
|
||||
#include <STEPundefined.h>
|
||||
#include <ExpDict.h>
|
||||
#include <STEPattribute.h>
|
||||
#include <complexSupport.h>
|
||||
|
||||
#include "cleditor/SdaiHeaderSchemaClasses.h"
|
||||
#include "cleditor/SdaiHeaderSchema.h"
|
||||
#include <SdaiHeaderSchemaClasses.h>
|
||||
#include <SdaiHeaderSchema.h>
|
||||
|
||||
SC_EDITOR_EXPORT void HeaderSchemaInit( Registry & );
|
||||
SC_EDITOR_EXPORT void HeaderInitSchemasAndEnts( Registry & );
|
||||
+2
-11
@@ -10,7 +10,8 @@
|
||||
* and is not subject to copyright.
|
||||
*/
|
||||
|
||||
#include "cleditor/cmdmgr.h"
|
||||
#include <cmdmgr.h>
|
||||
#include "sc_memmgr.h"
|
||||
|
||||
ReplicateLinkNode * ReplicateList::FindNode( MgrNode * mn ) {
|
||||
ReplicateLinkNode * rln = ( ReplicateLinkNode * )GetHead();
|
||||
@@ -71,16 +72,6 @@ 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 );
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
*/
|
||||
|
||||
#include <sc_export.h>
|
||||
#include "clutils/gennode.h"
|
||||
#include "clutils/gennodelist.h"
|
||||
#include "clutils/gennodearray.h"
|
||||
#include <gennode.h>
|
||||
#include <gennodelist.h>
|
||||
#include <gennodearray.h>
|
||||
|
||||
#include "cleditor/editordefines.h"
|
||||
#include "clstepcore/mgrnode.h"
|
||||
#include "clstepcore/mgrnodelist.h"
|
||||
#include "clstepcore/dispnode.h"
|
||||
#include "clstepcore/dispnodelist.h"
|
||||
#include "clstepcore/SingleLinkList.h"
|
||||
#include <editordefines.h>
|
||||
#include <mgrnode.h>
|
||||
#include <mgrnodelist.h>
|
||||
#include <dispnode.h>
|
||||
#include <dispnodelist.h>
|
||||
#include <SingleLinkList.h>
|
||||
|
||||
//#define NUM_CMDMGR_CMDS 9
|
||||
// this is the number of columns that contain cmds (as opposed
|
||||
@@ -145,7 +145,6 @@ class SC_EDITOR_EXPORT CmdMgr {
|
||||
public:
|
||||
|
||||
CmdMgr();
|
||||
~CmdMgr();
|
||||
|
||||
// STATE LIST OPERATIONS
|
||||
MgrNode * GetHead( stateEnum listType );
|
||||
@@ -20,10 +20,10 @@
|
||||
class MgrNode;
|
||||
class DisplayNode;
|
||||
class DisplayNodelist;
|
||||
#include "clstepcore/sdai.h"
|
||||
#include <sdai.h>
|
||||
//class SDAI_Application_instance;
|
||||
|
||||
#include "cleditor/editordefines.h"
|
||||
#include <editordefines.h>
|
||||
|
||||
class SC_EDITOR_EXPORT seeInfo : public DisplayNode {
|
||||
public:
|
||||
@@ -1,35 +1,55 @@
|
||||
set(LAZY_SRCS
|
||||
|
||||
set( clLazyFile_SRCS
|
||||
lazyDataSectionReader.cc
|
||||
lazyFileReader.cc
|
||||
lazyInstMgr.cc
|
||||
p21HeaderSectionReader.cc
|
||||
sectionReader.cc
|
||||
lazyP21DataSectionReader.cc
|
||||
judy.c
|
||||
)
|
||||
|
||||
set( SC_CLLAZYFILE_HDRS
|
||||
headerSectionReader.h
|
||||
lazyFileReader.h
|
||||
lazyP21DataSectionReader.h
|
||||
p21HeaderSectionReader.h
|
||||
lazyDataSectionReader.h
|
||||
lazyInstMgr.h
|
||||
lazyTypes.h
|
||||
sectionReader.h
|
||||
instMgrHelper.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/include/stepcode
|
||||
${SC_SOURCE_DIR}/src/cleditor
|
||||
${SC_SOURCE_DIR}/src/cldai
|
||||
${SC_SOURCE_DIR}/src/clstepcore
|
||||
${SC_SOURCE_DIR}/src/clutils
|
||||
${SC_SOURCE_DIR}/src/base
|
||||
${SC_SOURCE_DIR}/src/base/judy/src
|
||||
)
|
||||
|
||||
set(_libdeps stepcore stepdai steputils stepeditor)
|
||||
set(_libdeps stepcore stepdai steputils base stepeditor)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
SC_ADDLIB(steplazyfile SHARED SOURCES ${LAZY_SRCS} LINK_LIBRARIES ${_libdeps})
|
||||
SC_ADDLIB(steplazyfile SHARED SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps})
|
||||
if(WIN32)
|
||||
target_compile_definitions(steplazyfile PRIVATE SC_LAZYFILE_DLL_EXPORTS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_STATIC_LIBS)
|
||||
set(_libdeps stepcore-static stepdai-static steputils-static stepeditor-static)
|
||||
SC_ADDLIB(steplazyfile-static STATIC SOURCES ${LAZY_SRCS} LINK_LIBRARIES ${_libdeps})
|
||||
set(_libdeps stepcore-static stepdai-static steputils-static base-static stepeditor-static)
|
||||
SC_ADDLIB(steplazyfile-static STATIC SOURCES ${clLazyFile_SRCS} LINK_LIBRARIES ${_libdeps})
|
||||
endif()
|
||||
|
||||
SC_ADDEXEC(lazy_test SOURCES "lazy_test.cc;sc_benchmark.cc" LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL)
|
||||
SC_ADDEXEC(lazy_test SOURCES lazy_test.cc LINK_LIBRARIES steplazyfile stepeditor NO_INSTALL)
|
||||
target_compile_definitions(lazy_test PRIVATE NO_REGISTRY)
|
||||
|
||||
install(FILES ${SC_CLLAZYFILE_HDRS}
|
||||
DESTINATION ${INCLUDE_DIR}/stepcode/cllazyfile)
|
||||
|
||||
# Local Variables:
|
||||
# tab-width: 8
|
||||
# mode: cmake
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user