Return None for .name of enum if no name for value.

This fixes segfaults when trying to get the name of a dead key
from a qt key event.

Change-Id: Ie631e2245bca0a3fee8616854f6479d3dec0c2bb
Reviewed-by: Roman Lacko <backup.rlacko@gmail.com>
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Bump version number to 1.2.1

Change-Id: I96686740c2572818fce36de23cf2c16f127fdda9
Reviewed-by: Roman Lacko <backup.rlacko@gmail.com>
Reviewed-by: John Cumming <john@jsolutions.co.uk>
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Improve dependencies for tests

Add the global header and typesystem XML, and shiboken itself, as
dependencies to running Shiboken for generating the wrapped code used in
the unit tests. This gives a better example in case of users looking at
this code for how to do things in their own projects, and also makes
test writing easier by removing the need to do a clean build or touch
files to force the wrapping code to be recreated when modifying the test
code or the generator. Change command invocation to use shiboken as a
target name (CMake will recognize it as a target and use the correct
path automatically), and remove the now redundant dependency of the
wrapping libraries on the same. (This is superfluous both because using
shiboken as a target will cause CMake to add an implicit dependency on
it for users of the generated files, but also because it isn't really
needed; the generate command having it as a dependency covers needing it
built first, and is what we really care about as far as rebuilding
anything if it changes.)

Change-Id: If5cdf2e98602e500b49ba7b000e4e30e77e1a136
Reviewed-by: John Ehresman <jpe@wingware.com>
Fix '%#' substitution for # > 9

Change '%#' substitution to use a regular expression for the 'old' text
to enforce a word boundary after '#', such that we don't perform e.g.
'%1' replacement on inputs like '%10'. This fixes problems trying to
modify functions with more than nine arguments, such as the example from
the previous commit (which now compiles and passes). Also add a test
case for this.

Change-Id: I9956804b3c65bddf7e36838866641b24ceb87c57
Reviewed-by: John Ehresman <jpe@wingware.com>
Updated authors file

Change-Id: I43bc9ad2b32fc24bdbbc38728ae34e60ea843103
Reviewed-by: Roman Lacko <backup.rlacko@gmail.com>
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Clean up style

Change wrapping and indent of some code in Handler::startElement to
improve consistency.

Change-Id: I13bae6bbb732e3c5791cf0079154feed8d8dcbd1
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Fix description of sample/transform unit test

Change-Id: I942d2f450c8c57bed779925636a9abae572da98c
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Remove unnecessary line feed

Remove explicit '\n' from echo command in 'dist' target. This isn't
needed (echo should output one regardless, so it only creates an
additional empty line), and it is being parsed by CMake, which results
in generating a build.ninja on at least Windows that cannot be parsed
due to an unterminated string.

Change-Id: I5d8aba12c71f5a9c29a07108c50499081ba7203a
Reviewed-by: John Ehresman <jpe@wingware.com>
Work around MSVC's deficient <cmath>

Change libsample/transform.cpp to use the MSVC-specific _finite on
Windows, rather than std::isfinite, which MSVC does not implement.

Change-Id: If7b33e17bcb7c2e4432d670d44b559205f88796d
Reviewed-by: John Ehresman <jpe@wingware.com>
Write inititializations in topological order

Add methods to various places in the hierarchy so that the generator can
access the topologically ordered class list (in addition to the
unordered class list). Modify CppGenerator::finishGeneration to use
this.

This fixes a failure to correctly create Python wrapper classes due to
subclass wrappers being initialized before their base class (with the
result that the looked-up type object for the base class is null,
causing the derived class to be created without referencing the base).
Also change one of the test cases to test that we correctly wrap a
typedef of a template class derived from a non-template base (which was
failing before this change for the aforementioned reason).

Change-Id: Ib4dc2626a41cb7bb905ff4a302c2613ea12d026b
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Remove useless code.

Remove code to set the type entry base container type in
AbstractMetaBuilder::setupInheritance outside of setting up the
container meta class. We do it anyway when the meta class is found, and
fail if we can't find the meta class, so having just the type entry set
is not really useful. (And this will allow us to simplify the code going
forward.)

Change-Id: I90389efc574d516703df0d6a26ba130769adfea7
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Refactor and improve added function resolving

Add a public function to create an AddedFunction::TypeInfo from a
signature string. Change translateType to use this to do full recursive
resolution on template arguments. Create a new helper function to do
more intelligent parsing of template type name signatures, and use this
in translateType.

Taken together, this means that we now recognize both multiple arguments
to template types of added functions, as well as template arguments that
are themselves template types. We couldn't do this before due to the use
of a regular expression to attempt to separate the template type name
from its arguments. The test cases are updated to test these new
features.

Note, however, that it is now a fatal error if the template argument
type cannot be determined. (Before we would just drop it and treat the
type as a non-container.) However, 1) this should not be happening in a
well formed type system, and 2) it's questionable if things wouldn't
have fallen apart anyway from treating the presumed container as
something else.

Change-Id: I23c3a7f7e311e046642d951d6ad2236571fda6b8
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Revert "Remove useless code."

This reverts commit 02c6e63ac8dbb8acde3bc19abd36fff0db65fd11. Apparently
types derived from containers can have a container base class without
the container class having a metaclass.

This fixes the sample_strlist unit test crashing. (There may be another
bug here, in Shiboken's don't-write-generated-source-if-not-changed
logic, as the failure doesn't seem to reliably appear/disappear after an
incremental build.)

Change-Id: I5f60bfb784dca02d9766a32e7b7b8a8a529df5af
Reviewed-by: John Ehresman <jpe@wingware.com>
Fix finding container base classes

Move logic to find template classes to its own helper method, and newly
use the helper in AbstractMetaBuilder::getBaseClasses. This fixes the
latter not finding template base classes, which fixes class topological
sorting in some cases.

Unfortunately I have not figured out a reliable unit test for this,
although printing a debug warning when finding the parent fails (or when
a template lookup succeeds) is able to verify that this change is doing
something useful.

Change-Id: I2a5e0df4035393288b6f69ebc41dc0e64866a182
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Don't warn when inheriting from container

Change AbstractMetaBuilder::setupInheritance to not warn about classes
that inherit from known container types, even if the container type does
not have a corresponding wrapper class (which in many or most cases it
won't). Remove now-unneeded suppression for the same in 'sample'.

Change-Id: I0a45636791eba36cf070ea082eb6ead6cb5947ef
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Fix 'special' include handling

Fix handling of includes like '#include BOOST_USER_CONFIG'. This was
failing due to an obvious logic error in how the preprocessor tests if
the expanded symbol looks like an include file location.

Change-Id: Ia085e5c081078d328d6fc84ff2a99681913a30b9
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Fix buffer overrun processing macro definitions

Fix potential buffer overrun (__first iterator becomes > __last and
starts processing garbage) when parsing macro definitions that would
occur if a macro definition ends in a comment. This would cause the
macro definition to contain incorrect content or even outright garbage
(i.e. random memory) if the trailing comment is at the end of the file,
as in boost/type_traits/detail/type_trait_def.hpp. In this worst case,
the macro expansion could contain a NUL byte which would cause parsing
to prematurely halt at the point of expansion.

Change-Id: I94ded39d9a20dc9510d827bc18adb2dc1bad17f0
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Only use fields in PyTypeObject when defining types

Allocate and use separate structures for as_* fields in the PyTypeObject
rather than using fields in the PyHeapTypeObject.  This is a step
away from using the PyHeapTypeObject, which is unnecessary and will
make supporting stackless python easier.

Change-Id: I6e5c514ab6db5b8bee9bee3107b97d6fbd582641
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: John Cummings <jcummings2@users.sf.net>
Fix compilation issue on OS X 10.9

Starting with OS X 10.9 the system toolchain defaults to libc++.
This is a problem with the current sparse hash config as it defaults
to using  c++11 functionality under the std::tr1 namespace instead
of std, which fails for libc++ since it does not implement the tr1
namespace. This change allows libc++ based systems to use the correct
namespace.

Change-Id: Ia8dd49fb5fad2915f41e44240e45a7af9d6453a8
Reviewed-by: John Ehresman <jpe@wingware.com>
Fix for containers with 'const' values

Fix omission of 'const' specifier when generating binding code for
containers whose value type is 'const', which would lead to binding code
that does not compile due to 'const' mismatch. Includes test case.

Change-Id: Iff99a16ee071bb255f78e86e2456e5206cc00cfb
Reviewed-by: John Cummings <jcummings2@users.sf.net>