swig/swig — pull request #251 by ptomulik (2014-10-26 03:40:02+00:00)
Title: Initial implementation of strong and scoped enums in python

May look quite awkward for first sight, but this is a minimalistic approach to the matter. Primarily I've used the existing "class" machinery to emit classes that represent enums. The purpose of ``python/enums.i`` is to clear default typemaps for ``enum SWIGTYPE`` and define ``%typemap(constcode,...) enum SWIGTYPE``. The rest of the stuff is handled by default swig typemaps.

To enable strong/scoped types, one has to use ``%feature("python:enum",...). Obviously, this may be done per-module or per-declaration. Strong/scoped enums may be enabled globally -- new options ``-strongenum``, ``-scopedenum`` and ``-enumclass`` are provided for this purpose.

I have some doubts regarding memory management. No sure if I shouldn't use ``SWIG_POINTER_OWN`` in the ``constcode`` typemap. Currently this causes warnings about memory leaks, when running the test case.