Skip to content

Commit

Permalink
#31: adl/oct: Create enum-value-related Component Units
Browse files Browse the repository at this point in the history
- Committing my failures. Will fix!
  • Loading branch information
flisboac committed Mar 20, 2017
1 parent afc211d commit b4a01f1
Show file tree
Hide file tree
Showing 20 changed files with 508 additions and 75 deletions.
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ project(adl
VERSION 0.1.0
LANGUAGES CXX)
set(GLOBAL PROPERTY SONAME 0)
set(GLOBAL PROPERTY PROJECT_BRIEF "Abstract Domain Library, a C++ library implementing the octagon domain in CPU and GPU.")

# For C++14 support
set(CMAKE_CXX_STANDARD 14)
Expand Down Expand Up @@ -53,6 +54,8 @@ target_sources(${api} INTERFACE
"${api_dir_root}/adl.cfg.hpp"
"${api_dir_root}/adl/config.hpp"
"${api_dir_root}/adl/intl.hpp"
"${api_dir_root}/adl/error.fwd.hpp"
"${api_dir_root}/adl/error.hpp"

# adl/util
"${api_dir_root}/adl/util.hpp"
Expand Down Expand Up @@ -102,12 +105,32 @@ set(test_dir_root "${CMAKE_CURRENT_SOURCE_DIR}/test")
set(test_dir_unit "${CMAKE_CURRENT_SOURCE_DIR}/test/unit")
add_executable(${test}
"${test_dir_unit}/main.unit.cpp"

# adl
"${test_dir_unit}/adl/config.unit.cpp"
"${test_dir_unit}/adl/intl.unit.cpp"
"${test_dir_unit}/adl/error.unit.cpp"
)
target_link_libraries(${test} ${test_iapi})
enable_testing()
add_test(NAME ${test} COMMAND "./${test}")


#
# [ DOCUMENTATION GENERATION ]
#


find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)

#
# [ CMAKE DEBUGGING ]
#
Expand Down
16 changes: 8 additions & 8 deletions Doxyfile → Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = adl
PROJECT_NAME = @PROJECT_NAME@

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.1.0
PROJECT_NUMBER = @PROJECT_VERSION@

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.

PROJECT_BRIEF = "Abstract Domain Library, a C++ library implementing the octagon domain in CPU and GPU."
PROJECT_BRIEF = @PROJECT_BRIEF@

# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
Expand All @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = build/docs
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/docs

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -790,7 +790,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = include
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/include

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -889,7 +889,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*

EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = *.fwd.hpp

# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
Expand Down Expand Up @@ -2040,7 +2040,7 @@ ENABLE_PREPROCESSING = YES
# The default value is: NO.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

MACRO_EXPANSION = NO
MACRO_EXPANSION = YES

# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
# the macro expansion is limited to the macros specified with the PREDEFINED and
Expand Down Expand Up @@ -2080,7 +2080,7 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED =
PREDEFINED = @PROJECT_NAME@_BUILDING_DOCS

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
96 changes: 54 additions & 42 deletions include/adl.cfg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,6 @@
#ifndef adl__cfg__hpp__
#define adl__cfg__hpp__


//
// [[ DOCUMENTATION ]]
//

/**
* @def adl_NO_EXCEPTIONS
* If defined, sets adl_CONFIG_IS_USING_EXCEPTIONS to @c false.
* @sa adl_CONFIG_IS_USING_EXCEPTIONS
*/

/**
* @def adl_DEBUG
* If defined, sets adl_CONFIG_IS_DEBUG to @c true.
* @sa adl_CONFIG_IS_DEBUG
*/

/**
* @def adl_STRIPPED
* If defined, sets adl_CONFIG_IS_STRIPPED_BINARY to @c true.
* @sa adl_CONFIG_IS_STRIPPED_BINARY
*/

/**
* @def adl_CONFIG_IS_USING_EXCEPTIONS
* Determines if the library will default to throw exceptions on errors or not. The API is prepared to handle
* both cases, and some dependencies (e.g. OpenCL's cl2.hpp) may follow suit automatically.
*/

/**
* @def adl_CONFIG_IS_DEBUG
* If @c true, enables more runtime information. This flag acts more like an instruction for the implementation to
* output more information and than to reduce the binary size. For that, adl_STRIPPED should be defined.
*/

/**
* @def adl_CONFIG_IS_STRIPPED_BINARY
* If @c true, enables symbol stripping (at the language and TU level).
* Stripping removes additional debugging information and additional symbols. The resulting binary is therefore smaller.
* As of now, it disables error conditions' descriptions.
*/

//
// [[ CONFIGURABLE DEFINITIONS ]]
//
Expand All @@ -62,6 +20,8 @@
#define adl_CONFIG_VERSION_ABI 0 // Increased at each breaking change, major bump certainly bumps ABI version, minor bump should not (but may?) lead to abi bump


#ifndef adl_BUILDING_DOCS

//
// [[ PREPROCESSOR FLAGS ]]
//
Expand Down Expand Up @@ -223,4 +183,56 @@
#define adl_IMPL inline


#else

#define adl_API
#define adl_IAPI
#define adl_VAR
#define adl_IVAR
#define adl_CLASS
#define adl_ICLASS
#define adl_IMPL inline

//
// [[ DOCUMENTATION ]]
//

/**
* User-provided: If defined, sets adl_CONFIG_IS_USING_EXCEPTIONS to @c false.
* @sa adl_CONFIG_IS_USING_EXCEPTIONS
*/
#define adl_NO_EXCEPTIONS

/**
* User-provided: If defined, sets adl_CONFIG_IS_DEBUG to @c true.
* @sa adl_CONFIG_IS_DEBUG
*/
#define adl_DEBUG

/**
* User-provided: If defined, sets adl_CONFIG_IS_STRIPPED_BINARY to @c true.
* @sa adl_CONFIG_IS_STRIPPED_BINARY
*/
#define adl_STRIPPED

/**
* Determines if the library will default to throw exceptions on errors or not. The API is prepared to handle
* both cases, and some dependencies (e.g. OpenCL's cl2.hpp) may follow suit automatically.
*/
#define adl_CONFIG_IS_USING_EXCEPTIONS

/**
* If @c true, enables more runtime information. This flag acts more like an instruction for the implementation to
* output more information and than to reduce the binary size. For that, adl_STRIPPED should be defined.
*/
#define adl_CONFIG_IS_DEBUG

/**
* If @c true, enables symbol stripping (at the language and TU level).
* Stripping removes additional debugging information and additional symbols. The resulting binary is therefore smaller.
* As of now, it disables error conditions' descriptions.
*/
#define adl_CONFIG_IS_STRIPPED_BINARY

#endif // adl_BUILDING_DOCS
#endif // adl__cfg__hpp__
6 changes: 0 additions & 6 deletions include/adl.fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
/**
* @file adl.fwd.hpp
*/
#pragma once
#ifndef adl__fwd__hpp__
#define adl__fwd__hpp__

#include "adl.cfg.hpp"

adl_BEGIN_ROOT_MODULE


adl_END_ROOT_MODULE

#endif // adl__fwd__hpp__
2 changes: 1 addition & 1 deletion include/adl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/**
* @file adl.hpp
*/
#pragma once
#ifndef adl__hpp__
#define adl__hpp__

Expand All @@ -11,6 +10,7 @@
// Utility components/modules
#include "adl/config.hpp"
#include "adl/intl.hpp"
#include "adl/error.hpp"

// Main modules
#include "adl/util.hpp"
Expand Down
22 changes: 12 additions & 10 deletions include/adl/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@
/**
* @file config.hpp
*/
#pragma once
#ifndef adl__config__hpp__
#define adl__config__hpp__

#include "adl.cfg.hpp"

adl_BEGIN_MAIN_MODULE(config)
adl_BEGIN_ROOT_MODULE

constexpr char const* const name = adl_CONFIG_NAME_STR;
namespace version {
constexpr char const* const name = adl_CONFIG_VERSION_STR;
constexpr int const major = adl_CONFIG_VERSION_MAJOR;
constexpr int const minor = adl_CONFIG_VERSION_MINOR;
constexpr int const patch = adl_CONFIG_VERSION_PATCH;
constexpr int const abi = adl_CONFIG_VERSION_ABI;
namespace config {

constexpr char const* const name = adl_CONFIG_NAME_STR;
namespace version {
constexpr char const* const name = adl_CONFIG_VERSION_STR;
constexpr int const major = adl_CONFIG_VERSION_MAJOR;
constexpr int const minor = adl_CONFIG_VERSION_MINOR;
constexpr int const patch = adl_CONFIG_VERSION_PATCH;
constexpr int const abi = adl_CONFIG_VERSION_ABI;
}
}

adl_END_MAIN_MODULE
adl_END_ROOT_MODULE

#endif //adl__config__hpp__
45 changes: 45 additions & 0 deletions include/adl/error.fwd.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// $flisboac 2017-03-19
/**
* @file error.fwd.hpp
*/
#ifndef adl__error__fwd__hpp__
#define adl__error__fwd__hpp__


#include <type_traits>
#include <system_error>

#include "adl.cfg.hpp"


adl_BEGIN_ROOT_MODULE

//
// error.hpp
//

template <typename T> using enable_if_error_context_enum_t = std::enable_if_t<
std::is_error_condition_enum<T>::value, T>;
template <typename T> using enable_if_error_enum_t = std::enable_if_t<
std::is_error_condition_enum<T>::value || std::is_error_code_enum<T>::value, T>;

using error_id_type = int; // will always be int, for compatibility with <system_error> and everything else that's an error code
using error_condition = std::error_condition; // will not change, but for library use we have error_info
using error_code = std::error_code; // will not change

enum class error_kind_id;
using error_id = std::errc; // may be substituted in the future (and by that I mean before v1.0) by a custom enum class, but keeping the enum values already in use.

using error_category = std::error_category;
class library_error_kind_category;
class external_error_category;
using library_error_category = decltype(std::generic_category()); // when we get a custom error_id, library_category will have its own class as well
using error_info = error_condition; // In the future, error_info will be its own class, with the same interface as in error_condition and possibly additional contextual information (a la boost::exception).

class exception; // everything is a runtime_exception unless stated otherwise, language errors are not encapsulated (e.g. std::bad_*)
class client_exception; // errors that have origins on user-provided data or intervention (e.g. invalid arguments, etc)
class internal_exception; // error originated from the system, may be recoverable but it's not caused by users of the library

adl_END_ROOT_MODULE

#endif //adl__error__fwd__hpp__
Loading

0 comments on commit b4a01f1

Please sign in to comment.