swig/swig — pull request #250 by ptomulik (2014-10-25 21:18:42+00:00)
Title: Fix python global object constants

With current swig the following simple test case

```swig
%module object_constants

struct Type1 { };
%constant Type1 t1;

%{
struct Type1 {};
Type1 t1;
%}
```

does not compile, when generated with ``-builtin`` option. The compilation error is:

```console
swig -python -c++ -builtin -o object_constants_wrap.cxx object_constants.i
g++ -o object_constants_wrap.o -c -fpic -I. -I/usr/include/python2.7 object_constants_wrap.cxx
object_constants_wrap.cxx: In function ‘void init_object_constants()’:
object_constants_wrap.cxx:1170:83: error: ‘self’ was not declared in this scope
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags)
^
object_constants_wrap.cxx:4530:70: note: in expansion of macro ‘SWIG_NewPointerObj’
SWIG_Python_SetConstant(d, d == md ? public_interface : NULL, "t1",SWIG_NewPointerObj(SWIG_as_voidptr(&t1),SWIGTYPE_p_Type1, 0 ));
```

This patch fixes the problem.

**Advice needed**: I've set ``self`` to ``m`` (module) but maybe it should be ``NULL``? Please advise.