Started making the library sort-of-buildable

This commit is contained in:
Emmanuel BENOîT 2017-11-01 21:44:54 +01:00
parent 221f0c8ef8
commit ccd7cc30ef
55 changed files with 461 additions and 304 deletions

View file

@ -1,2 +1,2 @@
#!/bin/sh
make clean-extra
make fullclean

View file

@ -1,3 +1,3 @@
#!/bin/sh
make clean-extra
make fullclean
make -j 8 all

View file

@ -1,14 +1,14 @@
#!/bin/bash
if [ "$VIM_RELDIR" = "tests" ] && [ "$VIM_FILEEXT" = ".cc" ]; then
if make -j 8 all; then
if [ "$VIM_RELDIR" = "tests" ] && [ "$VIM_FILEEXT" = ".cc" ]; then
if [ -f "output/fast/test-$VIM_FILENOEXT" ]; then
LD_LIBRARY_PATH=./output/fast \
./output/fast/test-$VIM_FILENOEXT 2>&1 \
LD_LIBRARY_PATH=./output \
./output/test-$VIM_FILENOEXT 2>&1 \
| sed -e s/"$VIM_FILENAME"/'tests\/'"$VIM_FILENAME"/g
else
LD_LIBRARY_PATH=./output/fast \
./output/fast/run-all-tests 2>&1 \
exit 0
fi
fi
LD_LIBRARY_PATH=./output \
./output/run-all-tests 2>&1 \
| sed -e 's/^\([a-z\-]\+\.cc\)/tests\/\1/g'
fi
fi
fi

13
Makefile Normal file
View file

@ -0,0 +1,13 @@
CONFIG ?= default-config
export CONFIG
all: $(CONFIG)
+make -f Makefile.main
clean:
+make -f Makefile.main clean
fullclean:
+make -f Makefile.main fullclean
.PHONY: all clean fullclean

128
Makefile.main Normal file
View file

@ -0,0 +1,128 @@
include $(CONFIG)
CPPFLAGS += -Iinclude -I$(OUTDIR) -I$(OUTDIR)/data -DEBCL_BUILD
CXXFLAGS += -std=c++14 -Wall -Wextra
LDFLAGS += -L$(OUTDIR) -pthread
ifeq ($(OPTIMIZE),y)
CXXFLAGS += -O2
else
CXXFLAGS += -O0
endif
ifeq ($(DEBUG),y)
CXXFLAGS += -g
endif
CXXFLAGS_LIB = $(CXXFLAGS)
LIBS_LIB = -ldl -latomic
LIB_DYNAMIC = $(OUTDIR)/libebcorelib.so
LIB_STATIC = $(OUTDIR)/libebcorelib.a
LIB_TARGETS =
ifeq ($(BUILD_DYNAMIC_LIB),y)
CXXFLAGS_LIB += -fPIC
LIB_TARGETS += $(LIB_DYNAMIC)
endif
ifeq ($(BUILD_STATIC_LIB),y)
LIB_TARGETS += $(LIB_STATIC)
endif
include src/files.mk
LIB_OBJS = $(addprefix $(OUTDIR)/,$(addsuffix .o, $(subst src/,, $(basename $(LIB_SOURCES)))))
include tests/list.mk
TEST_SUITES := $(addprefix $(OUTDIR)/test-,$(TESTS))
TEST_ALL := $(OUTDIR)/run-all-tests
TEST_MAIN := $(OUTDIR)/tests/run-test.o
TEST_OBJS := $(addsuffix .o,$(addprefix $(OUTDIR)/tests/,$(TESTS))) $(TEST_MAIN)
LIBS_TESTS = -lcppunit
ifeq ($(BUILD_DYNAMIC_LIB),y)
LIBS_TESTS += -lebcorelib
TEST_NEEDS = $(LIB_DYNAMIC)
else
LIBS_TESTS += $(OUTDIR)/libebcorelib.a $(LIBS_LIB)
TEST_NEEDS = $(LIB_STATIC)
endif
ALL_OBJS = $(LIB_OBJS)
ifeq ($(BUILD_TESTS),y)
ALL_OBJS += $(TEST_OBJS)
endif
DEPS := $(addsuffix .d,$(ALL_OBJS))
TARGETS = $(LIB_TARGETS)
ifeq ($(BUILD_TESTS),y)
TARGETS += tests
endif
all: $(TARGETS)
run: tests
@if [ -z "$(E)" ]; then \
echo "\n\nPlease define E\n\n"; \
exit 1; \
else \
LD_LIBRARY_PATH=$(OUTDIR) $(OUTDIR)/$(E); \
fi
debug: tests
@if [ -z "$(E)" ]; then \
echo "\n\nPlease define E\n\n"; \
exit 1; \
else \
LD_LIBRARY_PATH=$(OUTDIR) debug $(OUTDIR)/$(E); \
fi
run-tests: tests
LD_LIBRARY_PATH=$(OUTDIR) ./$(TEST_ALL)
clean:
rm -f $(TEST_SUITES) $(TEST_ALL) $(TEST_OBJS) \
$(LIB_OBJS) $(LIB_TARGETS)
fullclean: clean
rm -f $(DEPS)
-rmdir $(sort $(dir $(TEST_OBJS)) $(dir $(LIB_OBJS)))
-rmdir $(OUTDIR)
tests: $(LIB_LWLIB) $(TEST_OBJS) $(TEST_SUITES) $(TEST_ALL)
.PHONY: all run debug run-tests clean fullclean tests
#------------------------------------------------------------------------------
# Actual building
-include $(DEPS)
# Library
$(LIB_DYNAMIC): $(LIB_OBJS)
$(CXX) $(LDFLAGS) -shared -Wl,-soname,$(notdir $(LIB_DYNAMIC)) \
-o $(LIB_DYNAMIC) \
$(LIB_OBJS) $(LIBS_LIB)
# Tests
$(TEST_SUITES): $(OUTDIR)/test-%: $(OUTDIR)/tests/%.o $(TEST_MAIN) $(TEST_NEEDS)
$(CXX) $(LDFLAGS) -o $@ $< $(TEST_MAIN) $(LIBS_TESTS)
$(TEST_ALL): $(TEST_OBJS) $(LIB_LWLIB)
$(CXX) $(LDFLAGS) -o $@ $(TEST_OBJS) $(LIBS_TESTS)
#------------------------------------------------------------------------------
# .cc -> .o
$(LIB_OBJS): $(OUTDIR)/%.o: src/%.cc
@if [ ! -d "$(dir $@)" ]; then mkdir -p "$(dir $@)"; fi
$(CXX) $(CPPFLAGS) $(CXXFLAGS_LIB) -c -o $@ $<
$(CXX) $(CPPFLAGS) $(CXXFLAGS_LIB) -M -MF $@.d -MT $@ $<
$(TEST_OBJS): $(OUTDIR)/%.o: %.cc
@if [ ! -d "$(dir $@)" ]; then mkdir -p "$(dir $@)"; fi
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -M -MF $@.d -MT $@ $<

12
default-config Normal file
View file

@ -0,0 +1,12 @@
# vim: syntax=make
BUILD_STATIC_LIB = n
BUILD_DYNAMIC_LIB = y
DEBUG = n
OPTIMIZE = y
BUILD_TESTS = y
OUTDIR = output
export BUILD_STATIC_LIB BUILD_DYNAMIC_LIB DEBUG OPTIMIZE BUILD_TESTS
export OUTDIR

View file

@ -4,10 +4,10 @@
#ifndef _H_EBCL_ALLOC
#define _H_EBCL_ALLOC
#include <lw/lib/Config.hh>
#include <lw/lib/Utilities.hh>
#include <ebcl/Config.hh>
#include <ebcl/Utilities.hh>
#include <atomic>
namespace lw {
namespace ebcl {
/* Helpers for pool allocators. */
@ -237,4 +237,4 @@ class T_ThreadedPoolAllocator
}
#endif //_H_EBCL_ALLOC
#include <lw/lib/inline/Alloc.hh>
#include <ebcl/inline/Alloc.hh>

View file

@ -4,11 +4,11 @@
#ifndef _H_EBCL_ARRAYS
#define _H_EBCL_ARRAYS
#include <lw/lib/Externals.hh>
#include <lw/lib/Pointers.hh>
#include <lw/lib/Utilities.hh>
#include <lw/lib/Types.hh>
namespace lw {
#include <ebcl/Externals.hh>
#include <ebcl/Pointers.hh>
#include <ebcl/Utilities.hh>
#include <ebcl/Types.hh>
namespace ebcl {
/*= DYNAMIC ARRAYS ===========================================================*/
@ -443,4 +443,4 @@ template<
}
#endif // _H_EBCL_ARRAYS
#include <lw/lib/inline/Arrays.hh>
#include <ebcl/inline/Arrays.hh>

View file

@ -2,9 +2,10 @@
/* BINARY READER/WRITER FOR STREAMS *******************************************/
/******************************************************************************/
#pragma once
#include <lw/lib/Streams.hh>
namespace lw {
#ifndef _H_EBCL_BINARYSTREAMS
#define _H_EBCL_BINARYSTREAMS
#include <ebcl/Streams.hh>
namespace ebcl {
/*= OBJECT READER/WRITER TEMPLATES ===========================================*/
@ -166,4 +167,5 @@ struct T_BinaryWriter
}
#include <lw/lib/inline/BinaryStreams.hh>
#include <ebcl/inline/BinaryStreams.hh>
#endif // _H_EBCL_BINARYSTREAMS

View file

@ -9,9 +9,10 @@
* buffer is a template argument) and dynamic (where the size can be changed).
*/
#pragma once
#include <lw/lib/Externals.hh>
namespace lw {
#ifndef _H_EBCL_BUFFERS
#define _H_EBCL_BUFFERS
#include <ebcl/Externals.hh>
namespace ebcl {
/*============================================================================*/
@ -101,4 +102,5 @@ class T_Buffer : public T_BufferBase
} // namespace
#include <lw/lib/inline/Buffers.hh>
#include <ebcl/inline/Buffers.hh>
#endif // _H_EBCL_BUFFERS

View file

@ -3,7 +3,8 @@
/******************************************************************************/
#pragma once
#ifndef _H_EBCL_EXTERNALS
#define _H_EBCL_EXTERNALS
#include <cstddef>
#include <cstdint>
@ -17,3 +18,5 @@
#include <shared_mutex>
#include <thread>
#include <utility>
#endif // _H_EBCL_EXTERNALS

View file

@ -2,10 +2,11 @@
/* HASH INDEX *****************************************************************/
/******************************************************************************/
#pragma once
#include <lw/lib/Externals.hh>
#include <lw/lib/Pointers.hh>
namespace lw {
#ifndef _H_EBCL_HASHINDEX
#define _H_EBCL_HASHINDEX
#include <ebcl/Externals.hh>
#include <ebcl/Pointers.hh>
namespace ebcl {
/*
@ -76,4 +77,5 @@ void swap( T_HashIndex& lhs , T_HashIndex& rhs ) noexcept;
} // namespace
#include <lw/lib/inline/HashIndex.hh>
#include <ebcl/inline/HashIndex.hh>
#endif // _H_EBCL_HASHINDEX

View file

@ -4,9 +4,9 @@
#ifndef _H_LW_LIB_HASHTABLES
#define _H_LW_LIB_HASHTABLES
#include <lw/lib/Arrays.hh>
#include <lw/lib/HashIndex.hh>
namespace lw {
#include <ebcl/Arrays.hh>
#include <ebcl/HashIndex.hh>
namespace ebcl {
// F_KeyMatch< K > - Equality check function for keys
@ -200,4 +200,4 @@ void swap( T_ObjectTable< K , T >& lhs , T_ObjectTable< K , T >& rhs );
}
#endif // _H_LW_LIB_HASHTABLES
#include <lw/lib/inline/HashTables.hh>
#include <ebcl/inline/HashTables.hh>

View file

@ -2,10 +2,10 @@
/* POINTERS *******************************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_POINTERS
#define _H_LW_LIB_POINTERS
#include <lw/lib/Utilities.hh>
namespace lw {
#ifndef _H_EBCL_POINTERS
#define _H_EBCL_POINTERS
#include <ebcl/Utilities.hh>
namespace ebcl {
template< typename T > class T_OwnPtr;
template< typename T > class T_SharedPtr;
@ -419,5 +419,5 @@ template<
} // namespace
#endif // _H_LW_LIB_POINTERS
#include <lw/lib/inline/Pointers.hh>
#endif // _H_EBCL_POINTERS
#include <ebcl/inline/Pointers.hh>

View file

@ -2,12 +2,13 @@
/* STREAMS ********************************************************************/
/******************************************************************************/
#pragma once
#include <lw/lib/Externals.hh>
#include <lw/lib/Utilities.hh>
#include <lw/lib/Pointers.hh>
#include <lw/lib/Buffers.hh>
namespace lw {
#ifndef _H_EBCL_STREAMS
#define _H_EBCL_STREAMS
#include <ebcl/Externals.hh>
#include <ebcl/Utilities.hh>
#include <ebcl/Pointers.hh>
#include <ebcl/Buffers.hh>
namespace ebcl {
/*= STREAM ERRORS ============================================================*/
@ -107,4 +108,5 @@ class A_OutputStream : public A_Stream
M_ABSTRACT_POINTERS( OutputStream );
} // namespace
#include <lw/lib/inline/Streams.hh>
#include <ebcl/inline/Streams.hh>
#endif // _H_EBCL_STREAMS

View file

@ -2,13 +2,13 @@
/* STRINGS AND RELATED UTILITIES **********************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_STRINGS
#define _H_LW_LIB_STRINGS
#include <lw/lib/Externals.hh>
#include <lw/lib/Pointers.hh>
#include <lw/lib/Arrays.hh>
#include <lw/lib/BinaryStreams.hh>
namespace lw {
#ifndef _H_EBCL_STRINGS
#define _H_EBCL_STRINGS
#include <ebcl/Externals.hh>
#include <ebcl/Pointers.hh>
#include <ebcl/Arrays.hh>
#include <ebcl/BinaryStreams.hh>
namespace ebcl {
/*= UTF-8 UTILITY FUNCTIONS ==================================================*/
@ -453,5 +453,5 @@ M_LSHIFT_OP( T_StringBuilder , double );
} // namespace
#endif // _H_LW_LIB_STRINGS
#include <lw/lib/inline/Strings.hh>
#endif // _H_EBCL_STRINGS
#include <ebcl/inline/Strings.hh>

View file

@ -2,12 +2,12 @@
/* THREADING ******************************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_THREADING
#define _H_LW_LIB_THREADING
#ifndef _H_EBCL_THREADING
#define _H_EBCL_THREADING
#include <lw/lib/Pointers.hh>
#include <lw/lib/Arrays.hh>
namespace lw {
#include <ebcl/Pointers.hh>
#include <ebcl/Arrays.hh>
namespace ebcl {
/*= ALIASES ==================================================================*/
@ -146,5 +146,5 @@ void swap( T_RingBuffer< T >& lhs , T_RingBuffer< T >& rhs ) noexcept;
}
#endif // _H_LW_LIB_THREADING
#include <lw/lib/inline/Threading.hh>
#endif // _H_EBCL_THREADING
#include <ebcl/inline/Threading.hh>

View file

@ -2,11 +2,11 @@
/* CONTAINER TYPES ************************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_TYPES
#define _H_LW_LIB_TYPES
#include <lw/lib/Utilities.hh>
#include <lw/lib/Pointers.hh>
namespace lw {
#ifndef _H_EBCL_TYPES
#define _H_EBCL_TYPES
#include <ebcl/Utilities.hh>
#include <ebcl/Pointers.hh>
namespace ebcl {
/*= VARIANT TYPE =============================================================*/
@ -494,5 +494,5 @@ template< typename... Types >
} // namespace
#endif // _H_LW_LIB_TYPES
#include <lw/lib/inline/Types.hh>
#endif // _H_EBCL_TYPES
#include <ebcl/inline/Types.hh>

View file

@ -2,10 +2,10 @@
/* VARIOUS UTILITIES **********************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_UTILITIES
#define _H_LW_LIB_UTILITIES
#include <lw/lib/Externals.hh>
namespace lw {
#ifndef _H_EBCL_UTILITIES
#define _H_EBCL_UTILITIES
#include <ebcl/Externals.hh>
namespace ebcl {
// IsPowerOf2( v ) - Is some integer a power of 2 ?
@ -310,7 +310,7 @@ struct T_Comparator
#define M_DEFINE_COMPARATOR( Type ) \
int T_Comparator< Type >::compare( Type const & a , Type const & b )
int ::ebcl::T_Comparator< Type >::compare( Type const & a , Type const & b )
// Instantiate some commonly used comparators
extern template struct T_Comparator< uint32_t >;
@ -389,5 +389,5 @@ class A_PrivateImplementation
} // namespace
#endif // _H_LW_LIB_UTILITIES
#include <lw/lib/inline/Utilities.hh>
#endif // _H_EBCL_UTILITIES
#include <ebcl/inline/Utilities.hh>

View file

@ -2,10 +2,10 @@
/* ALLOCATORS - INLINE CODE ***************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_INLINE_ALLOC
#define _H_LW_LIB_INLINE_ALLOC
#include <lw/lib/Alloc.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_ALLOC
#define _H_EBCL_INLINE_ALLOC
#include <ebcl/Alloc.hh>
namespace ebcl {
/*= T_PoolHelper::T_List =====================================================*/
@ -373,4 +373,4 @@ void T_ThreadedPoolAllocator< OS , OA , P , M >::addToStack(
}
#endif //_H_LW_LIB_INLINE_ALLOC
#endif //_H_EBCL_INLINE_ALLOC

View file

@ -2,10 +2,10 @@
/* ARRAYS - INLINE CODE *******************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_INLINE_ARRAYS
#define _H_LW_LIB_INLINE_ARRAYS
#include <lw/lib/Arrays.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_ARRAYS
#define _H_EBCL_INLINE_ARRAYS
#include <ebcl/Arrays.hh>
namespace ebcl {
/*= T_Array ==================================================================*/
@ -1591,4 +1591,4 @@ inline T_Array< T > const& T_AutoArray< T , S , G >::dynamic_( ) const noexcept
} // namespace
#endif // _H_LW_LIB_INLINE_ARRAYS
#endif // _H_EBCL_INLINE_ARRAYS

View file

@ -2,9 +2,10 @@
/* BINARY READER/WRITER FOR STREAMS - INLINE CODE *****************************/
/******************************************************************************/
#pragma once
#include <lw/lib/BinaryStreams.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_BINARYSTREAMS
#define _H_EBCL_INLINE_BINARYSTREAMS
#include <ebcl/BinaryStreams.hh>
namespace ebcl {
/*= T_BinaryReader ===========================================================*/
@ -143,3 +144,4 @@ inline void T_BinaryWriter::T_Writer_< T , false >::write( T_BinaryWriter const&
} // namespace
#endif // _H_EBCL_INLINE_BINARYSTREAMS

View file

@ -2,9 +2,10 @@
/* BUFFERS - INLINE CODE ******************************************************/
/******************************************************************************/
#pragma once
#include <lw/lib/Buffers.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_BUFFERS
#define _H_EBCL_INLINE_BUFFERS
#include <ebcl/Buffers.hh>
namespace ebcl {
/*= T_BufferBase =============================================================*/
@ -261,3 +262,4 @@ inline T_Buffer< T >& T_Buffer< T >::copyAll( T const* data )
} // namespace
#endif // _H_EBCL_INLINE_BUFFERS

View file

@ -2,9 +2,10 @@
/* HASH INDEX - INLINE CODE ***************************************************/
/******************************************************************************/
#pragma once
#include <lw/lib/HashIndex.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_HASHINDEX
#define _H_EBCL_INLINE_HHASHINDEX
#include <ebcl/HashIndex.hh>
namespace ebcl {
/*= T_HashIndex ==============================================================*/
@ -27,3 +28,4 @@ inline uint32_t T_HashIndex::next( uint32_t index ) const
}
#endif //_H_EBCL_INLINE_HHASHINDEX

View file

@ -2,10 +2,10 @@
/* HASH TABLES - INLINE CODE **************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_INLINE_HASHTABLES
#define _H_LW_LIB_INLINE_HASHTABLES
#include <lw/lib/HashTables.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_HASHTABLES
#define _H_EBCL_INLINE_HASHTABLES
#include <ebcl/HashTables.hh>
namespace ebcl {
/*= T_DefaultKeyMatch ========================================================*/
@ -418,4 +418,4 @@ inline uint32_t T_ObjectTable< K , V >::find( K const& k , uint32_t hash ) const
} // namespace
#endif // _H_LW_LIB_INLINE_HASHTABLES
#endif // _H_EBCL_INLINE_HASHTABLES

View file

@ -2,10 +2,10 @@
/* POINTERS - INLINE CODE *****************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_INLINE_POINTERS
#define _H_LW_LIB_INLINE_POINTERS
#include <lw/lib/Pointers.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_POINTERS
#define _H_EBCL_INLINE_POINTERS
#include <ebcl/Pointers.hh>
namespace ebcl {
/*= T_OwnPtr =================================================================*/
@ -851,4 +851,4 @@ template<
} // namespace
#endif // _H_LW_LIB_INLINE_POINTERS
#endif // _H_EBCL_INLINE_POINTERS

View file

@ -2,9 +2,10 @@
/* STREAMS - INLINE CODE ******************************************************/
/******************************************************************************/
#pragma once
#include <lw/lib/Streams.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_STREAMS
#define _H_EBCL_INLINE_STREAMS
#include <ebcl/Streams.hh>
namespace ebcl {
/*= X_StreamError ============================================================*/
@ -96,3 +97,4 @@ inline A_OutputStream::A_OutputStream( size_t position , size_t size ) noexcept
} // namespace
#endif // _H_EBCL_INLINE_STREAMS

View file

@ -2,10 +2,10 @@
/* STRINGS AND RELATED UTILITIES - INLINE CODE ********************************/
/******************************************************************************/
#ifndef _H_LW_LIB_INLINE_STRINGS
#define _H_LW_LIB_INLINE_STRINGS
#include <lw/lib/Strings.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_STRINGS
#define _H_EBCL_INLINE_STRINGS
#include <ebcl/Strings.hh>
namespace ebcl {
/*= T_Character ==============================================================*/
@ -588,4 +588,4 @@ inline T_StringBuilder& operator<< ( T_StringBuilder& sb , double value )
} // namespace
#endif // _H_LW_LIB_INLINE_STRINGS
#endif // _H_EBCL_INLINE_STRINGS

View file

@ -2,10 +2,10 @@
/* THREADING - INLINE CODE ****************************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_INLINE_THREADING
#define _H_LW_LIB_INLINE_THREADING
#include <lw/lib/Threading.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_THREADING
#define _H_EBCL_INLINE_THREADING
#include <ebcl/Threading.hh>
namespace ebcl {
/*= T_ReadWriteMutex =========================================================*/
@ -349,4 +349,4 @@ inline void T_RingBuffer< T >::expand( )
}
#endif // _H_LW_LIB_INLINE_THREADING
#endif // _H_EBCL_INLINE_THREADING

View file

@ -2,10 +2,10 @@
/* CONTAINER TYPES - INLINE CODE **********************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_INLINE_TYPES
#define _H_LW_LIB_INLINE_TYPES
#include <lw/lib/Types.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_TYPES
#define _H_EBCL_INLINE_TYPES
#include <ebcl/Types.hh>
namespace ebcl {
/*= VARIANT TYPE =============================================================*/
@ -126,7 +126,7 @@ inline void T_VariantHelper::T_InPlaceHandler< Type >::action(
case E_HandlerOp::MKHDL:
{
const E_HandlerMode mode( *( (E_HandlerMode*) &source ) );
const E_HandlerMode mode( *new ((char*)&source) E_HandlerMode );
if ( mode == E_HandlerMode::IN_PLACE ) {
*( (F_Handler*) dest) = &T_InPlaceHandler< Type >::action;
} else {
@ -230,7 +230,7 @@ inline void T_VariantHelper::T_HeapHandler< Type >::action(
case E_HandlerOp::MKHDL:
{
const E_HandlerMode mode( *( (E_HandlerMode*) &source ) );
const E_HandlerMode mode( *new ((char*)&source) E_HandlerMode );
if ( mode == E_HandlerMode::IN_PLACE ) {
*( (F_Handler*) dest) = &T_InPlaceHandler< Type >::action;
} else {
@ -996,5 +996,5 @@ inline void T_Union< TL... >::moveImpl( T_Storage_* from , T_Storage_* to )
} // namespace
#endif // _H_LW_LIB_INLINE_TYPES
#endif // _H_EBCL_INLINE_TYPES

View file

@ -2,10 +2,10 @@
/* VARIOUS UTILITIES - INLINE CODE ********************************************/
/******************************************************************************/
#ifndef _H_LW_LIB_INLINE_UTILITIES
#define _H_LW_LIB_INLINE_UTILITIES
#include <lw/lib/Utilities.hh>
namespace lw {
#ifndef _H_EBCL_INLINE_UTILITIES
#define _H_EBCL_INLINE_UTILITIES
#include <ebcl/Utilities.hh>
namespace ebcl {
template< typename T >
@ -300,4 +300,4 @@ inline void A_PrivateImplementation::callPrivateDestructor( ) noexcept
}
#endif // _H_LW_LIB_INLINE_UTILITIES
#endif // _H_EBCL_INLINE_UTILITIES

View file

@ -3,9 +3,9 @@
/******************************************************************************/
#include <lw/lib/HashIndex.hh>
#include <lw/lib/Utilities.hh>
using namespace lw;
#include <ebcl/HashIndex.hh>
#include <ebcl/Utilities.hh>
using namespace ebcl;
/*= T_HashIndex =============================================================*/
@ -93,7 +93,7 @@ T_HashIndex& T_HashIndex::operator =( T_HashIndex&& other ) noexcept
/*----------------------------------------------------------------------------*/
void lw::swap( T_HashIndex& lhs , T_HashIndex& rhs ) noexcept
void ebcl::swap( T_HashIndex& lhs , T_HashIndex& rhs ) noexcept
{
using std::swap;

View file

@ -2,10 +2,10 @@
/* POINTERS *******************************************************************/
/******************************************************************************/
#include <lw/lib/Alloc.hh>
#include <lw/lib/Config.hh>
#include <lw/lib/Pointers.hh>
using namespace lw;
#include <ebcl/Alloc.hh>
#include <ebcl/Config.hh>
#include <ebcl/Pointers.hh>
using namespace ebcl;
/*= T_WeakChain_ =============================================================*/
@ -48,8 +48,8 @@ namespace {
static T_ThreadedPoolAllocator<
sizeof( T_Reference_ ) , alignof( T_Reference_ ) ,
LW_CFG_SHAREDPTR_REFPOOL_SIZE ,
LW_CFG_SHAREDPTR_REFPOOL_MAXFREE
EBCL_CFG_SHAREDPTR_REFPOOL_SIZE ,
EBCL_CFG_SHAREDPTR_REFPOOL_MAXFREE
> ReferenceAllocator_;
}

View file

@ -2,9 +2,8 @@
/* STREAMS ********************************************************************/
/******************************************************************************/
#include <lw/lib/Streams.hh>
using namespace lw;
#include <ebcl/Streams.hh>
using namespace ebcl;
/*= X_StreamError ============================================================*/

View file

@ -4,14 +4,14 @@
#include <atomic>
#include <lw/lib/Strings.hh>
#include <lw/lib/HashIndex.hh>
#include <lw/lib/Threading.hh>
#include <lw/lib/Types.hh>
#include <lw/lib/Alloc.hh>
#include <ebcl/Strings.hh>
#include <ebcl/HashIndex.hh>
#include <ebcl/Threading.hh>
#include <ebcl/Types.hh>
#include <ebcl/Alloc.hh>
using namespace lw;
using namespace ebcl;
/*= STRING STORAGE AND POOLING CLASSES =======================================*/
@ -142,12 +142,12 @@ class T_StringPool final
} // namespace
namespace lw { M_DECLARE_HASH( A_StringDataInternal ); }
namespace ebcl { M_DECLARE_HASH( A_StringDataInternal ); }
/*= UTF-8 UTILITY FUNCTIONS ==================================================*/
bool lw::UTF8IsValid( char const* string )
bool ebcl::UTF8IsValid( char const* string )
{
assert( string != nullptr );
@ -211,7 +211,7 @@ bool lw::UTF8IsValid( char const* string )
/*----------------------------------------------------------------------------*/
uint32_t lw::UTF8Length( char const* string )
uint32_t ebcl::UTF8Length( char const* string )
{
assert( string != nullptr );
@ -236,7 +236,7 @@ uint32_t lw::UTF8Length( char const* string )
/*----------------------------------------------------------------------------*/
uint32_t lw::UTF8Size( char const* string )
uint32_t ebcl::UTF8Size( char const* string )
{
assert( string != nullptr );
@ -259,7 +259,7 @@ uint32_t lw::UTF8Size( char const* string )
/*----------------------------------------------------------------------------*/
bool lw::UTF8Info( char const* string , uint32_t& size , uint32_t& length )
bool ebcl::UTF8Info( char const* string , uint32_t& size , uint32_t& length )
{
assert( string != nullptr );
@ -314,7 +314,7 @@ bool lw::UTF8Info( char const* string , uint32_t& size , uint32_t& length )
/*----------------------------------------------------------------------------*/
bool lw::UTF8BufferInfo( char const* data , uint32_t size , uint32_t& length )
bool ebcl::UTF8BufferInfo( char const* data , uint32_t size , uint32_t& length )
{
assert( data != nullptr );
@ -378,7 +378,7 @@ bool lw::UTF8BufferInfo( char const* data , uint32_t size , uint32_t& length )
/*----------------------------------------------------------------------------*/
uint32_t lw::UTF8GetCodepoint( char const* data , uint32_t& bytes )
uint32_t ebcl::UTF8GetCodepoint( char const* data , uint32_t& bytes )
{
assert( data != nullptr );
if ( ( data[ 0 ] & 0xf8 ) == 0xf0 ) {
@ -407,7 +407,7 @@ uint32_t lw::UTF8GetCodepoint( char const* data , uint32_t& bytes )
/*----------------------------------------------------------------------------*/
uint32_t lw::UTF8GetCodepoint( char const* data )
uint32_t ebcl::UTF8GetCodepoint( char const* data )
{
assert( data != nullptr );
if ( ( data[ 0 ] & 0xf8 ) == 0xf0 ) {
@ -432,7 +432,7 @@ uint32_t lw::UTF8GetCodepoint( char const* data )
/*----------------------------------------------------------------------------*/
uint32_t lw::UTF8PutCodepoint( char* output , uint32_t available , uint32_t codepoint )
uint32_t ebcl::UTF8PutCodepoint( char* output , uint32_t available , uint32_t codepoint )
{
if ( codepoint < 0x80 && available >= 1 ) {
*output = char( codepoint );
@ -458,7 +458,7 @@ uint32_t lw::UTF8PutCodepoint( char* output , uint32_t available , uint32_t code
/*----------------------------------------------------------------------------*/
uint32_t lw::UTF8GetMemoryOffset( char const* input , uint32_t index )
uint32_t ebcl::UTF8GetMemoryOffset( char const* input , uint32_t index )
{
assert( input != nullptr );
@ -481,7 +481,7 @@ uint32_t lw::UTF8GetMemoryOffset( char const* input , uint32_t index )
/*----------------------------------------------------------------------------*/
uint64_t lw::UTF8ToUnsignedInteger( char const* input , uint32_t size , bool * ok ,
uint64_t ebcl::UTF8ToUnsignedInteger( char const* input , uint32_t size , bool * ok ,
int base , bool useSep , uint32_t separator )
{
char const* inputPos( input );
@ -595,7 +595,7 @@ uint64_t lw::UTF8ToUnsignedInteger( char const* input , uint32_t size , bool * o
/*----------------------------------------------------------------------------*/
int64_t lw::UTF8ToInteger( char const* input , uint32_t size , bool * ok ,
int64_t ebcl::UTF8ToInteger( char const* input , uint32_t size , bool * ok ,
int base , bool useSep , uint32_t separator )
{
char const* inputPos( input );
@ -717,7 +717,7 @@ int64_t lw::UTF8ToInteger( char const* input , uint32_t size , bool * ok ,
/*----------------------------------------------------------------------------*/
double lw::UTF8ToDouble( char const* input , uint32_t size ,
double ebcl::UTF8ToDouble( char const* input , uint32_t size ,
bool * ok , uint32_t decimalPoint ,
bool useSep , uint32_t separator )
{
@ -1187,7 +1187,7 @@ T_StringIterator& T_StringIterator::operator= ( T_StringIterator const& other )
/*----------------------------------------------------------------------------*/
void lw::swap( T_StringIterator& lhs , T_StringIterator& rhs ) noexcept
void ebcl::swap( T_StringIterator& lhs , T_StringIterator& rhs ) noexcept
{
using std::swap;
swap( lhs.data_ , rhs.data_ );
@ -1320,7 +1320,7 @@ T_String& T_String::operator= ( T_StringBuilder const& sb )
/*----------------------------------------------------------------------------*/
void lw::swap( T_String& lhs , T_String& rhs ) noexcept
void ebcl::swap( T_String& lhs , T_String& rhs ) noexcept
{
using std::swap;
swap( lhs.data_ , rhs.data_ );
@ -1745,7 +1745,7 @@ T_StringBuilder::~T_StringBuilder( )
/*----------------------------------------------------------------------------*/
void lw::swap( T_StringBuilder& lhs , T_StringBuilder& rhs )
void ebcl::swap( T_StringBuilder& lhs , T_StringBuilder& rhs )
{
using std::swap;
swap( lhs.data_ , rhs.data_ );

View file

@ -2,13 +2,11 @@
/* INSTANTIATION OF VARIOUS TEMPLATE CLASSES **********************************/
/******************************************************************************/
#include <lw/lib/Utilities.hh>
#include <lw/lib/Arrays.hh>
#include <lw/lib/Strings.hh>
#include <lw/lib/SRDData.hh>
#include <lw/lib/SRDDefinitions.hh>
#include <ebcl/Utilities.hh>
#include <ebcl/Arrays.hh>
#include <ebcl/Strings.hh>
namespace lw {
namespace ebcl {
/*----------------------------------------------------------------------------*/
@ -19,8 +17,6 @@ template struct T_Comparator< uint32_t >;
template class T_Array< uint32_t >;
template class T_Array< bool >;
template class T_Array< T_String >;
template class T_Array< T_SRDToken >;
template class T_Array< T_SRDInputItem >;
/*----------------------------------------------------------------------------*/

View file

@ -3,8 +3,8 @@
/******************************************************************************/
#include <lw/lib/Utilities.hh>
using namespace lw;
#include <ebcl/Utilities.hh>
using namespace ebcl;
namespace {
@ -143,7 +143,7 @@ void T_Sorter_::sort( uint8_t* data , uint32_t itemSize , uint32_t items , F_Swa
/*= HashData( ) ==============================================================*/
uint32_t lw::HashData( uint8_t const* data , uint32_t size )
uint32_t ebcl::HashData( uint8_t const* data , uint32_t size )
{
uint32_t hash = 111119;
while ( size > 0 ) {

View file

@ -1,36 +1,34 @@
MINLIB_SOURCES = \
src/lib/Files.cc \
src/lib/HashIndex.cc \
src/lib/MemoryStreams.cc \
src/lib/Pointers.cc \
src/lib/SRDBinary.cc \
src/lib/SRDData.cc \
src/lib/SRDDefinitions.cc \
src/lib/SRDIO.cc \
src/lib/SRDParser.cc \
src/lib/SRDParserConfig.cc \
src/lib/SRDPreproc.cc \
src/lib/SRDPPCommands.cc \
src/lib/SRDText.cc \
src/lib/Streams.cc \
src/lib/Strings.cc \
src/lib/TemplateInstantiation.cc \
src/lib/Utilities.cc \
src/lib/VFS.cc \
src/lib/VFSDrivers.cc
# FIXME: VFSDrivers shouldn't be in the minlib
# (but we need it for srdpp at this point)
LIB_SOURCES = \
$(MINLIB_SOURCES) \
src/lib/Console.cc \
src/lib/ConsoleLogWriter.cc \
src/lib/CwdFileLogger.cc \
src/lib/DynLib.cc \
src/lib/GameLoop.cc \
src/lib/LW.cc \
src/lib/Log.cc \
src/lib/Messages.cc \
src/lib/ModInterface.cc \
src/lib/Mods.cc \
src/lib/TextFileLogger.cc
src/HashIndex.cc \
src/Pointers.cc \
src/Streams.cc \
src/Strings.cc \
src/TemplateInstantiation.cc \
src/Utilities.cc \
# END
#
# src/Files.cc \
# src/MemoryStreams.cc \
# src/SRDBinary.cc \
# src/SRDData.cc \
# src/SRDDefinitions.cc \
# src/SRDIO.cc \
# src/SRDParser.cc \
# src/SRDParserConfig.cc \
# src/SRDPreproc.cc \
# src/SRDPPCommands.cc \
# src/SRDText.cc \
# src/VFS.cc \
# src/VFSDrivers.cc \
# src/Console.cc \
# src/ConsoleLogWriter.cc \
# src/CwdFileLogger.cc \
# src/DynLib.cc \
# src/GameLoop.cc \
# src/LW.cc \
# src/Log.cc \
# src/Messages.cc \
# src/ModInterface.cc \
# src/Mods.cc \
# src/TextFileLogger.cc

View file

@ -1,6 +1,6 @@
#include <lw/lib/Arrays.hh>
#include <ebcl/Arrays.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class ArraysAutoTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Arrays.hh>
#include <ebcl/Arrays.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class ArraysBasicTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Arrays.hh>
#include <ebcl/Arrays.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class ArraysMultiTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Arrays.hh>
#include <ebcl/Arrays.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class ArraysObjectsTest : public CppUnit::TestFixture
@ -201,13 +201,12 @@ void swap( T_Test& lhs , T_Test& rhs )
} // namespace
namespace lw {
M_DECLARE_COMPARATOR( T_Test );
namespace ebcl { M_DECLARE_COMPARATOR( T_Test ); }
M_DEFINE_COMPARATOR( T_Test )
{
return T_Comparator< uint32_t >::compare( a.serial , b.serial );
}
} // namespace lw
void ArraysObjectsTest::tearDown( )
{

View file

@ -1,6 +1,6 @@
#include <lw/lib/Arrays.hh>
#include <ebcl/Arrays.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class ArraysStaticBasicTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Arrays.hh>
#include <ebcl/Arrays.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class ArraysStaticObjectsTest : public CppUnit::TestFixture
@ -179,13 +179,11 @@ void swap( T_TestObject_& lhs , T_TestObject_& rhs )
} // namespace
namespace lw {
M_DECLARE_COMPARATOR( T_TestObject_ );
namespace ebcl { M_DECLARE_COMPARATOR( T_TestObject_ ); }
M_DEFINE_COMPARATOR( T_TestObject_ )
{
return T_Comparator< uint32_t >::compare( a.serial , b.serial );
}
} // namespace lw
void ArraysStaticObjectsTest::tearDown( )
{

View file

@ -1,9 +1,10 @@
#include <lw/lib/Utilities.hh>
#include <ebcl/Utilities.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
/* - ComputeHashTest ---------------------------------------------------{{{-*/
/* - ComputeHashTest -------------------------------------------------------*/
class ComputeHashTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( ComputeHashTest );
@ -25,7 +26,7 @@ public:
CPPUNIT_TEST_SUITE_REGISTRATION( ComputeHashTest );
void ComputeHashTest::testInt8( ) // {{{
void ComputeHashTest::testInt8( )
{
const uint8_t t8u = 1;
const int8_t t8su = 1 , t8ss = -1;
@ -34,8 +35,7 @@ void ComputeHashTest::testInt8( ) // {{{
CPPUNIT_ASSERT_EQUAL( uint32_t( 0xff ) , ComputeHash( t8ss ) );
}
// }}}
void ComputeHashTest::testInt16( ) // {{{
void ComputeHashTest::testInt16( )
{
const uint16_t t16u = 1;
const int16_t t16su = 1, t16ss = -1;
@ -44,8 +44,7 @@ void ComputeHashTest::testInt16( ) // {{{
CPPUNIT_ASSERT_EQUAL( uint32_t( 0xffff ) , ComputeHash( t16ss ) );
}
// }}}
void ComputeHashTest::testInt32( ) // {{{
void ComputeHashTest::testInt32( )
{
uint32_t t32u = 1;
int32_t t32su = 1, t32ss = -1;
@ -54,8 +53,7 @@ void ComputeHashTest::testInt32( ) // {{{
CPPUNIT_ASSERT_EQUAL( uint32_t( 0xffffffff ) , ComputeHash( t32ss ) );
}
// }}}
void ComputeHashTest::testInt64( ) // {{{
void ComputeHashTest::testInt64( )
{
uint64_t t64u = 0x100000010L;
int64_t t64s = -1;
@ -63,8 +61,7 @@ void ComputeHashTest::testInt64( ) // {{{
CPPUNIT_ASSERT_EQUAL( uint32_t( 0 ) , ComputeHash( t64s ) );
}
// }}}
void ComputeHashTest::testStructDefault( ) // {{{
void ComputeHashTest::testStructDefault( )
{
struct T_Test_ {
uint8_t meh[ 16 ];
@ -77,7 +74,3 @@ void ComputeHashTest::testStructDefault( ) // {{{
CPPUNIT_ASSERT_EQUAL( uint32_t( HashData( test.meh , 16 ) ) ,
ComputeHash( test ) );
}
// }}}
/*------------------------------------------------------------------------}}}-*/

View file

@ -1,6 +1,6 @@
#include <lw/lib/HashIndex.hh>
#include <ebcl/HashIndex.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class HashIndexTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/HashTables.hh>
#include <ebcl/HashTables.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class KeyValueTableTest : public CppUnit::TestFixture

View file

@ -1,6 +1,4 @@
TESTS = \
alloc-pool \
buffers \
ptr-owned \
ptr-shared \
ptr-weak \
@ -17,37 +15,41 @@ TESTS = \
hash-index \
key-value-table \
object-table \
ring-buffer \
strings \
strings-iterator \
strings-storage \
strings-builder \
binary-reader \
binary-writer \
stream-file-input \
srd-bin-reader \
srd-bin-writer \
srd-lexer \
srd-text-writer \
srd-mem-target \
srd-parser \
srd-parser-defs \
srd-parser-cfg \
srd-preproc-core \
srd-preproc-cmd-core \
srd-preproc-cmd-variables \
srd-preproc-cmd-functions \
srd-preproc-cmd-macros \
srd-preproc-cmd-introspect \
srd-preproc-cmd-compare \
srd-preproc-cmd-casts \
srd-preproc-cmd-arithmetic \
srd-preproc-cmd-logic \
srd-preproc-cmd-strings \
srd-preproc-cmd-misc \
srd-preproc-cmd-input \
srd-preproc-tracking \
log-data \
console-text \
console-edit \
vfs
#TESTS = \
# alloc-pool \
# buffers \
# ring-buffer \
# strings \
# strings-iterator \
# strings-storage \
# strings-builder \
# binary-reader \
# binary-writer \
# stream-file-input \
# srd-bin-reader \
# srd-bin-writer \
# srd-lexer \
# srd-text-writer \
# srd-mem-target \
# srd-parser \
# srd-parser-defs \
# srd-parser-cfg \
# srd-preproc-core \
# srd-preproc-cmd-core \
# srd-preproc-cmd-variables \
# srd-preproc-cmd-functions \
# srd-preproc-cmd-macros \
# srd-preproc-cmd-introspect \
# srd-preproc-cmd-compare \
# srd-preproc-cmd-casts \
# srd-preproc-cmd-arithmetic \
# srd-preproc-cmd-logic \
# srd-preproc-cmd-strings \
# srd-preproc-cmd-misc \
# srd-preproc-cmd-input \
# srd-preproc-tracking \
# log-data \
# console-text \
# console-edit \
# vfs

View file

@ -1,6 +1,6 @@
#include <lw/lib/HashTables.hh>
#include <ebcl/HashTables.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class ObjectTableTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Types.hh>
#include <ebcl/Types.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class OptionalTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Pointers.hh>
#include <ebcl/Pointers.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class OwnPointerTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Pointers.hh>
#include <ebcl/Pointers.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class SharedPointerTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Pointers.hh>
#include <ebcl/Pointers.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class WeakPointerTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Types.hh>
#include <ebcl/Types.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class UnionTest : public CppUnit::TestFixture

View file

@ -1,6 +1,6 @@
#include <lw/lib/Types.hh>
#include <ebcl/Types.hh>
#include <cppunit/extensions/HelperMacros.h>
using namespace lw;
using namespace ebcl;
class VariantTest : public CppUnit::TestFixture