Index: wxproj.cpp
===================================================================
RCS file: /thubanrepository/thuban/libraries/thuban/wxproj.cpp,v
retrieving revision 1.4
diff -c -r1.4 wxproj.cpp
*** wxproj.cpp	25 Feb 2004 10:33:24 -0000	1.4
--- wxproj.cpp	16 Feb 2005 13:16:04 -0000
***************
*** 10,20 ****
   * data with proj4 and draw it on a wxWindows DC
   */
  
  #include <stdlib.h>
  #include <math.h>
  
- #include <Python.h>
- 
  #include <shapefil.h>
  #include "pyshapelib_api.h"
  
--- 10,20 ----
   * data with proj4 and draw it on a wxWindows DC
   */
  
+ #include <Python.h>
+ 
  #include <stdlib.h>
  #include <math.h>
  
  #include <shapefil.h>
  #include "pyshapelib_api.h"
  
***************
*** 30,80 ****
  
  #include <wx/wx.h>
  
! 
! static PyShapeLibAPI * pyshapelib_api;
! 
! /* helper function to extract the pointer value from a swig ptr string
   */
- static void *
- decode_pointer(char *string)
- {
-   unsigned long p = 0;
- 
-   /* Pointer values must start with leading underscore */
-   if (*string == '_')
-   {
-       string++;
-       /* Extract hex value from pointer */
-       while (*string)
-       {
- 	  if ((*string >= '0') && (*string <= '9'))
- 	    p = (p << 4) + (*string - '0');
- 	  else if ((*string >= 'a') && (*string <= 'f'))
- 	    p = (p << 4) + ((*string - 'a') + 10);
- 	  else
- 	    break;
- 	  string++;
-       }
-   }
-   return (void*)p;
- }
- 
- /* Return the object wrapped by the SWIG shadow object shadow */
- static void*
- get_pointer(PyObject* shadow)
- {
-     PyObject * string;
-     void * result = NULL;
  
!     string = PyObject_GetAttrString(shadow, "this");
!     if (string && PyString_Check(string))
!     {
! 	result = decode_pointer(PyString_AsString(string));
!     }
!     Py_XDECREF(string);
  
-     return result;
- }
  
  /* Extract a pointer from a python object that has a cobject method.
   *
--- 30,51 ----
  
  #include <wx/wx.h>
  
! /* For wx2.5, we cannot just extract the address of the object from the
!  * Python string repr; we need to go through the Swig mechanisms
!  */
! #include "swigPtrConvertHack.h"
! //#include <wx/wxPython/wxPython.h>
! /* We only need this prototype from the above (big) include:
!  * 
!  * bool wxPyConvertSwigPtr( PyObject* obj, void **ptr, const wxChar* className);
!  * 
!  * but it is a macro involving a large struct and static variables, so we
!  * can't just get along with a prototype.
!  * Trouble is this file is not installed by default on Debian.
   */
  
! static PyShapeLibAPI * pyshapelib_api;
  
  
  /* Extract a pointer from a python object that has a cobject method.
   *
***************
*** 289,307 ****
  
      draw_info->py_dc = py_dc;
      Py_INCREF(draw_info->py_dc);
!     draw_info->dc = (wxDC*)get_pointer(draw_info->py_dc);
!     if (!draw_info->dc)
!     {
  	PyErr_SetString(PyExc_TypeError,
  			"third argument must be a wxDC instance");
  	goto fail;
      }
! 
      draw_info->py_forward = py_forward;
      Py_INCREF(draw_info->py_forward);
      if (!extract_pointer(draw_info->py_forward, &draw_info->forward))
! 	goto fail;
! 
      draw_info->py_inverse = py_inverse;
      Py_INCREF(draw_info->py_inverse);
      if (!extract_pointer(draw_info->py_inverse, &draw_info->inverse))
--- 260,278 ----
  
      draw_info->py_dc = py_dc;
      Py_INCREF(draw_info->py_dc);
!     if (!wxPyConvertSwigPtr( py_dc, 
! 			    (void**)&(draw_info->dc), 
! 			    wxT("wxDC") )){
  	PyErr_SetString(PyExc_TypeError,
  			"third argument must be a wxDC instance");
  	goto fail;
      }
!     
      draw_info->py_forward = py_forward;
      Py_INCREF(draw_info->py_forward);
      if (!extract_pointer(draw_info->py_forward, &draw_info->forward))
! 	    goto fail;
! 	    
      draw_info->py_inverse = py_inverse;
      Py_INCREF(draw_info->py_inverse);
      if (!extract_pointer(draw_info->py_inverse, &draw_info->inverse))
***************
*** 351,358 ****
      }
      else
      {
! 	pen = (wxPen*)get_pointer(pen_shadow);
! 	if (!pen)
  	{
  	    PyErr_SetString(PyExc_TypeError,
  		       "fourth argument must be a wxPen instance or None");
--- 322,328 ----
      }
      else
      {
! 	if (!wxPyConvertSwigPtr( pen_shadow, (void**)&pen, wxT("wxPen")))
  	{
  	    PyErr_SetString(PyExc_TypeError,
  		       "fourth argument must be a wxPen instance or None");
***************
*** 366,373 ****
      }
      else
      {
! 	brush = (wxBrush*)get_pointer(brush_shadow);
! 	if (!brush)
  	{
  	    PyErr_SetString(PyExc_TypeError,
  			"fifth argument must be a wxBrush instance or None");
--- 336,342 ----
      }
      else
      {
! 	if (!wxPyConvertSwigPtr( brush_shadow, (void**)&brush, wxT("wxBrush")))
  	{
  	    PyErr_SetString(PyExc_TypeError,
  			"fifth argument must be a wxBrush instance or None");
