diff --git a/enum.h b/enum.h index a164fdb..490a7e7 100644 --- a/enum.h +++ b/enum.h @@ -306,14 +306,8 @@ constexpr bool _namesMatchNocase(const char *stringizedName, _namesMatchNocase(stringizedName, referenceName, index + 1); } -#define _ENUM_NOT_FOUND ((size_t)-1) - -/// Functions and types used to compute range properties such as the minimum and -/// maximum declared enum values, and the total number of valid enum values. -namespace _range { - template constexpr UnderlyingType _findMinLoop(const UnderlyingType *values, size_t valueCount, size_t index, @@ -351,16 +345,7 @@ constexpr UnderlyingType _findMax(const UnderlyingType *values, size_t count) return _findMaxLoop(values, count, 1, values[0]); } -} // namespace _range -} // namespace _enum - -// TODO Note that the static_assert for _rawSize > 0 never really gets a chance -// to fail in practice, because the preprocessor macros break before that. - - - -namespace _enum { // TODO Consider reserving memory statically. This will probably entail a great // compile-time slowdown, however. @@ -439,6 +424,8 @@ template class _GeneratedArrays; \ } +#define _ENUM_NOT_FOUND ((size_t)-1) + template class _Enum : public _GeneratedArrays { protected: @@ -456,10 +443,8 @@ class _Enum : public _GeneratedArrays { constexpr static const _Enumerated _first = _value_array[0]; constexpr static const _Enumerated _last = _value_array[_size - 1]; - constexpr static const _Enumerated _min = - _range::_findMin(_value_array, _size); - constexpr static const _Enumerated _max = - _range::_findMax(_value_array, _size); + constexpr static const _Enumerated _min = _findMin(_value_array, _size); + constexpr static const _Enumerated _max = _findMax(_value_array, _size); constexpr static const size_t _span = _max - _min + 1; @@ -669,7 +654,7 @@ class _Enum : public _GeneratedArrays { \ } -} +} // namespace _enum #define ENUM(EnumType, UnderlyingType, ...) \ _ENUM_TAG_DECLARATION(EnumType); \ diff --git a/enum_preprocessor_map.h b/enum_preprocessor_map.h index 2bc5291..55433c2 100644 --- a/enum_preprocessor_map.h +++ b/enum_preprocessor_map.h @@ -1,4 +1,4 @@ -/// @file EnumPreprocessorMap.h +/// @file enum_preprocessor_map.h /// @brief Preprocessor higher-order map macro. /// /// This file was automatically generated by pp_map_gen.py diff --git a/pp_map_gen.py b/pp_map_gen.py index ae9cbec..abf150e 100755 --- a/pp_map_gen.py +++ b/pp_map_gen.py @@ -88,10 +88,15 @@ if __name__ == '__main__': if len(sys.argv) != 3: print >> sys.stderr, 'Usage: ' + sys.argv[0] + ' FILE COUNT' print >> sys.stderr, '' - print >> sys.stderr, 'Prints macro header file to standard output.' - print >> sys.stderr, 'The FILE parameter is used in the comment.' - sys.exit(2) + print >> sys.stderr, 'Prints map macro definition to FILE.' + sys.exit(1) + + output_file = open(sys.argv[1], "w") + + try: + generate(output_file, sys.argv[1], int(sys.argv[2]), + os.path.basename(sys.argv[0])) + finally: + output_file.close() - generate(sys.stdout, sys.argv[1], int(sys.argv[2]), - os.path.basename(sys.argv[0])) sys.exit(0)