
vÅÏ^	  ã               @   s'   d  d l  m Z Gd d „  d ƒ Z d S)é    )Úc_void_pc               @   sa   e  Z d  Z d Z d Z e Z d Z e Z	 e
 d d „  ƒ Z e j d d „  ƒ Z d d „  Z d S)ÚCPointerBasezz
    Base class for objects that have a pointer access property
    that controls access to the underlying C pointer.
    Nc             C   s-   |  j  r |  j  S|  j d |  j j ƒ ‚ d  S)NzNULL %s pointer encountered.)Ú_ptrÚnull_ptr_exception_classÚ	__class__Ú__name__)Úself© r	   ú8/tmp/pip-build-8lau8j11/django/django/contrib/gis/ptr.pyÚptr   s    	zCPointerBase.ptrc             C   sA   | d  k p t  | |  j ƒ s4 t d t | ƒ ƒ ‚ | |  _ d  S)NzIncompatible pointer type: %s.)Ú
isinstanceÚptr_typeÚ	TypeErrorÚtyper   )r   r   r	   r	   r
   r      s    c             C   sH   |  j  rD |  j rD y |  j  |  j ƒ Wn t t t f k
 rC Yn Xd S)z9
        Free the memory used by the C++ object.
        N)Ú
destructorr   r   ÚAttributeErrorÚImportErrorr   )r   r	   r	   r
   Ú__del__   s
    zCPointerBase.__del__)r   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   Úpropertyr   Úsetterr   r	   r	   r	   r
   r      s   r   N)Úctypesr   r   r	   r	   r	   r
   Ú<module>   s   