75 Commits

Author SHA1 Message Date
Anton Bachin
9a2389cd15 Eliminated non-integral underlying types.
This was an experimental feature. Removing it to simplify maintenance.
2015-10-04 18:34:57 -05:00
Anton Bachin
c1d4a1c006 Fixed #ifdef that caused some tests not to run.
Disabled some tests that were failing due to unsupported type traits in
Travis standard library installation.
2015-10-04 12:34:19 -05:00
Anton Bachin
e1e237a4ea Renamed top-level macro ENUM to BETTER_ENUM.
To reduce name clashes.

Fixes #11.
2015-10-04 11:03:08 -05:00
Anton Bachin
977f8ef145 Replaced testing on G++ 5.1 with G++ 5.2.
GCC 5.2 is a "bugfix" release over GCC 5.1 - not sure why the GCC team
updated the minor version number. Package managers seem to have dropped
GCC 5.1 and replaced it with 5.2, and I'm guessing usage of 5.1 is
discouraged. The testing code has been updated accordingly.

Travis is still distributing GCC 5.1 as of the time of this writing.
2015-08-23 12:41:42 -05:00
Anton Bachin
0595a526e7 Updated AppVeyor configuration.
Since VS2015 RTM, AppVeyor provides an image that has both VS2015 and
Cygwin pre-installed. Before this change, I had combined the build
matrix into one row, because of the need to install Cygwin in each
build worker, which is a 10-15-minute process. Since this is no longer
necessary, the matrix is restored. AppVeyor builds are now very fast.
2015-08-23 12:38:56 -05:00
Anton Bachin
eac6afacdc Bidirectional maps between enums and any types.
Also added a C++14 configuration to testing, but using it only for
bidrectional map testing at the moment.
2015-07-11 19:32:28 -05:00
Anton Bachin
0f816be0cd Restored clang 3.6 and 3.5 in the Travis build.
Now that llvm.org is back up and Travis is able to download the
compiler binaries.
2015-07-11 17:29:09 -05:00
Anton Bachin
60a4f4dfda Updated documentation. 2015-07-11 15:27:43 -05:00
Anton Bachin
f404ea709b Made N4428 implementation more exact.
See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4428.pdf
2015-07-11 15:25:48 -05:00
Anton Bachin
30efe7ccd7 Temporarily removed clang 3.5 and 3.6 in Travis.
I am still testing against these locally. Travis is having difficulty
installing them in build instances, perhaps due to the current llvm.org
outage.
2015-07-11 15:19:34 -05:00
Anton Bachin
6c3d02b951 Fixed bug that disallowed some constant names.
The user-supplied constant names are used to declare an internal enum
type. They end up sharing a namespace with some internal library
values. Those internal values had names not prefixed with underscores.
As a result, it was impossible to declare enum constants with these
names.

Prefixed the internal names with underscores.
2015-07-11 10:23:34 -05:00
Anton Bachin
f1a0b5d0e4 Simple implementation of N4428 enum reflection. 2015-07-09 18:29:44 -05:00
Anton Bachin
b182e16ec3 Local testing on VC2010 and VC2012.
Also improved the documentation Makefile not to re-generate the samples
unless the source Markdown files are newer. This should make samples
development easier.
2015-07-09 18:28:11 -05:00
Anton Bachin
9273051e07 Updated documentation and appearance. 0.10.1 2015-07-09 00:38:45 -05:00
Anton Bachin
7cfd738c1a Included VC2008 in AppVeyor and local testing.
Also reordered compilers so that the very first tested are the ones
that support the most configurations, then immediately followed by
those which are the most likely to fail. Typically, this would be the
oldest ones, or the compiler versions that were the first to support
some major features.
2015-07-08 09:25:48 -05:00
Anton Bachin
6278793a0b Added workarounds for VC2008.
VC2008 has two quirks. It generates linking errors if a copy
constructor is not explicitly defined on a Better Enum, and it has a
buggy interaction between the ternary operator and throw. This change
detects VC2008 and generates alternative code for that compiler.

Having an explicitly-defined copy constructor in a literal type appears
to cause an internal compiler error in g++4.7, and causes a spurious
compilation failure in g++4.8. For this reason, the copy constructor
generation is conditioned on the compiler.

The replacement code for the ternary operator is also generated
conditionally, because it uses an if-statement. The normal code has to
compile in a constexpr context, and so has to use the ternary operator
instead of the if-statement.

Resolves #6.
2015-07-07 11:22:40 -05:00
Anton Bachin
124c09f2f0 Sped up the AppVeyor build.
Current AppVeyor images with VC2015 don't have Cygwin pre-installed, so
each row in the build matrix installs it before running the build. This
takes about 7-8 minutes per row.

This change combines all the VC testing into one row, so the price of
installing Cygwin is paid only once. A secondary improvement is that
individual rows don't have to wait in the AppVeyor queue. Builds now
take a total of about 15 minutes, instead of approximately an hour,
including queueing time.

This change should probably be undone once there is an AppVeyor image
that comes with both VC2015 and Cygwin. The main AppVeyor image has VC
up to 2013 and Cygwin, so I suppose VC2015 and Cygwin will be available
once a final version of VC2015 is released.

Until then, Better Enums does not have the benefit of separate rows in
the AppVeyor build matrix.
2015-07-02 18:17:06 -05:00
Anton Bachin
89a1c1a64b Updated CONTRIBUTING.md and related information. 2015-07-02 16:56:33 -05:00
Alexander Buddenbrock
1769fbb6b7 Added support for testing in Travis. 2015-07-02 15:51:01 -05:00
Anton Bachin
07fef34465 Not assuming bash in testing scripts. 2015-07-02 10:56:37 -05:00
Anton Bachin
3c3733c700 Support for testing in AppVeyor.
Tests are run for VC2010, VC2012, VC2013, VC2015.
2015-07-01 23:58:23 -05:00
Anton Bachin
ba9139e075 Switched to CMake for building tests.
To run tests with the system compiler, execute

    make

To run tests with the system compiler in all configurations,

    make default-all

To re-generate the examples from the documentation Markdown, and then
test all configurations,

    make default-thorough

Other Makefile targets are for exhaustive testing with multiple
locally-installed compilers, or for use on CI servers, and are not for
general use.

Python and CxxTest are still required. On Windows, it is helpful to
have a Cygwin environment with a non-Cygwin CMake, and MSBuild.exe
should be in PATH.

Better Enums is now tested in fewer configurations. C++11 features are
no longer tested on clang 3.3, gcc 4.3-4.6, because CMake claims
(apparently falsely, in some cases) that those compilers don't support
constexpr and enum class.
2015-07-01 15:18:48 -05:00
Anton Bachin
535f7f151b Fixed char16_t and char32_t detection for clang.
These are now only assumed in C++11 mode. long long is also assumed
only in C++11 mode for clang, which may make some programs that rely on
long long as an extension in C++98 fail with Better Enums. I will solve
that at a later date if it becomes a problem.
2015-07-01 15:11:29 -05:00
Alexander Buddenbrock
54b7a054be Only apply the Cygwin fix on Windows.
The so called 'cygwin_fix_command' replaces all instances of '/home'
with 'C:/cygwin/home'. This will cause the tests to fail on linux as
this directory does not exist there.
2015-06-27 18:30:03 -05:00
Anton Bachin
faf3676fec Made it easier to generate offline documentation.
Documentation can be generated by going to doc/ and running "make".
This requires Python. Before this change, the user had to install the
mistune library, which is used by the generator. The mistune library is
now included in the Better Enums distribution.

The generated docs are available at doc/html/index.html. Note that some
links won't be local (the GitHub repo, the download link, outgoing
links to MSDN, tutorial source in the GitHub repo, and so on). All the
pages belonging to the actual docs will be local, however.

The online version of the docs can be generated by running "make web".
The only difference between the online and offline versions is that the
former includes Google Analytics tracking code, and may include social
communication buttons, comment section, or other useless things in the
future.

Also included errata since the last release.

Resolves #2.
2015-06-27 13:56:27 -05:00
Anton Bachin
9a02379937 Updated README. 2015-06-20 17:00:49 -05:00
Anton Bachin
f5f669277a Updated documentation. 0.10.0 2015-06-20 13:11:56 -05:00
Anton Bachin
d90bfd6f18 Fixed some warnings with strict flags. 2015-06-20 11:50:26 -05:00
Anton Bachin
9810dd07ce Changed _size to a function.
An alternative constant _size_constant is provided for use in C++98,
for example for declaring arrays.

Also renamed underlying_traits to integral_mapping.
2015-06-19 17:05:33 -05:00
Anton Bachin
aa34aad468 Simplified underlying type traits.
Removed the function are_equal. Comparison is now done by converting
operands to their integral representation, and comparing those. Also
restored ordering of enum values along the same lines (according to
integral representation).
2015-06-15 19:29:39 -05:00
Anton Bachin
a493e90ac4 Initialization now always completed before main.
Before this change, in C++98 and C++11 "fast" mode, initializer
trimming was done "lazily" the first time _to_string or _names was
called. To make performance more "predictable", an object with static
storage is now used to force initializaton during program start-up,
when static object constructors are called.

The benefit of this change is very debatable. I had to give the static
object static linkage to avoid duplicate symbols, so there is a copy
now in each translation unit. I hope this does not increase code size
too much in realistic scenarios.

Lazy initialization checks are still performed and cannot be removed,
because other objects with static storage may try to use an enum from
their constructors before the enum's initialization is forced.
2015-06-15 18:32:57 -05:00
Anton Bachin
fc609e58aa Internal clean-up. 2015-06-15 10:48:05 -05:00
Anton Bachin
74b3a66284 Eliminated dynamic allocation.
When compile-time stringized constant name trimming is disabled (off by
default), trimming happens "lazily" - the first time the user calls a
function such as _to_string, the function allocates space for trimmed
constant names and trims them there.

With this change, space is reserved statically in a writeable char
array, and trimming happens in that array instead.
2015-06-13 16:22:07 -05:00
Anton Bachin
98232ee4fb Made enum.h build with exceptions disabled.
Throwing functions are simply omitted.
2015-06-12 17:17:41 -05:00
Anton Bachin
7502ae3c18 Included enum type names in exception messages. 2015-06-12 14:06:59 -05:00
Anton Bachin
11a1c26494 Internal improvements to stream operators. 2015-06-12 12:56:51 -05:00
Anton Bachin
0f63667106 Overloaded stream operators.
To avoid paying the huge penalty of including iostream and string for
users that don't need those headers, and to avoid creating a second,
optional header file, I resorted to defining the operators as templates
to prevent type checking until the user tries to actually use them. The
stream types and strings are wrapped in a metafunction that depends on
the template parameter. This is basically a hack, but it seems to work.
2015-06-11 23:05:46 -05:00
Anton Bachin
4314ad3fd3 Experimental generalization of underlying types.
With this change, the underlying type can be a non-integral type that
provides conversions to and from an integral type. See the test at
test/cxxtest/underlying.h for some examples - though they are more
verbose than strictly necessary, for testing needs.

Move constructors in underlying types are not supported. It has been
difficult so far to get constexpr code not to select the move
constructor, which is generally not constexpr, for various operations.
2015-06-11 20:39:46 -05:00
Anton Bachin
b037d8b5eb Improved test.py to for multiple test files and Cygwin. 2015-06-10 15:58:32 -05:00
Anton Bachin
5edcb3e121 Made ENUM usable in namespaces. 2015-06-07 17:05:31 -05:00
Anton Bachin
97197088fe Updated contact information and other errata. 2015-06-06 13:54:40 -05:00
Anton Bachin
820fd22b5f Added CONTRIBUTING file and acknowledgements. 2015-06-05 21:57:33 -05:00
Anton Bachin
41508fb114 Eliminated underscored internal macro names.
Also made a few documentation changes.
2015-06-05 19:20:18 -05:00
Anton Bachin
b24d155b7b Updated and improved documentation. 0.9.0 2015-06-05 13:01:28 -05:00
Anton Bachin
3a316e6f79 Made the test script use only the system compiler by default and extended some
support to VC++.

The unit test is currently not being run on VC++ due to a problem with CxxTest,
Cygwin, and paths. However, the examples are being compiled and having their
output checked, and the multiple translation unit test is being run.

Running "(cd test ; ./test.py)" should now run tests only using the default
compiler, on a Unix-like system. test.py --all runs tests on the full array of
compilers that I have installed and symlinked on my development machines.
2015-05-27 18:40:39 -05:00
Anton Bachin
ccc7858f14 Ported to Microsoft Visual Studio.
Worked around a bug with vararg macro expansion in VC++ and tested with Visual
Studio 2013. This commit does not include exhaustive tests for that compiler as
for clang and gcc. They are coming in a follow-on commit.

https://connect.microsoft.com/VisualStudio/feedback/details/521844/variadic-macro-treating-va-args-as-a-single-parameter-for-other-macros
2015-05-27 13:20:14 -05:00
Anton Bachin
2acb5743fa Complete documentation and testing overhaul.
The documentation is now generated from markdown. Samples are generated from the
tutorial pages. Testing is done by a Python script which runs the tests for a
large number of compilers.

This version is not very developer-friendly - the Python scripts need ways of
limiting what compilers they try to run. If you don't have 15 compilers
installed, you won't be able to run the tests in this commit. Fix coming soon.
2015-05-27 09:58:34 -05:00
Anton Bachin
a9ddc59808 Simplified enum.h.
This patch contains several minor changes.
- Eliminated the use of a deleted constructor in C++11. C++98 private default
  constructor is sufficient.
- Eliminated old namespace _enum and merged it with namespace better_enums.
- Prefixed size_t with std:: to comply with standards more strictly.
- Shortened feature control macros by deleting the word "FORCE".

Also moved make_macros.py.
2015-05-27 09:12:41 -05:00
Anton Bachin
a757e27891 Rewrote unit tests to work for multiple configurations. 2015-05-27 09:05:10 -05:00
Anton Bachin
b4be7537b6 Fixed bug with missing constructor deletion, removed reference to nullptr. 2015-05-27 09:05:10 -05:00