//==============================================================================
// %(Identifier)s - interface Python wrapper prototypes
//==============================================================================

#ifndef __Interface__%(PreprocIdentifier)s__PYTHON__H__
#define __Interface__%(PreprocIdentifier)s__PYTHON__H__

#include <Python.h>


%(OpenNamespace)s

PyTypeObject *%(Identifier)s_init( );

%(CloseNamespace)s

#endif

<<<<<<<SPLIT>>>>>>>
//==============================================================================
// %(Identifier)s - interface Python wrapper definitions - <MInterfaceDef>
//==============================================================================

#include "Python_Converter/%(Identifier)s_python.h"
%(IncludeLocalHeader)s
#include <CCM_Python/BasicTypes.h>
%(CodaConvertInclude)s
%(CodaResultInclude)s

%(MOperationDefInclude)s
%(MOperationDefRetIncludeGen)s

%(UsingLocalNamespace)s
%(MOperationDefRetUsingGen)s

%(OpenNamespace)s

static PyObject *Py%(Identifier)s_exception = 0;

// ---------- casac.aipserror ----------
extern PyObject *casac_aipserror( );
// ---------- casac.indexerror ----------
extern PyObject *casac_indexerror( );

//
//  ------  interface object struct  ------
//
typedef struct {
  PyObject_HEAD
  WX::Utils::SmartPtr<%(Identifier)s> *interface;
} Py%(Identifier)s_object;

//
//  ------  attributes  ------
//
%(MAttributeDefImpl)s

//
//  ------  operations  ------
//
%(MOperationDefWrapper)s

//
//  ------  interface destructor  ------
//
static void
Py%(Identifier)s_dealloc( Py%(Identifier)s_object *self ) {
    self->ob_type->tp_free( (PyObject*) self );
}

//
// ------  interface constructor  ------
//
static PyObject *
Py%(Identifier)s_new( PyTypeObject *type, PyObject *args, PyObject *keywds ) {
    Py%(Identifier)s_object *self = (Py%(Identifier)s_object*) type->tp_alloc(type,0);
    // do any local allocation here
    return (PyObject*) self;
}

//
// ------  interface initialization  ------
//
static int
Py%(Identifier)s_init( Py%(Identifier)s_object *self, PyObject *args, PyObject *keywds ) {

    if ( ! args || ! PyCObject_Check(args) ) {
        PyErr_SetString( Py%(Identifier)s_exception, "error with local %(Identifier)s pointer" );
	return -1;
    }

    self->interface = (WX::Utils::SmartPtr<%(Identifier)s>*) PyCObject_AsVoidPtr(args);
    return 0;
}


static PyGetSetDef Py%(Identifier)s_getset[] = {
%(MAttributeDefGetSet)s
  {NULL}								/* Sentinel */
};
//
// ------  interface method table  ------
//
static PyMethodDef Py%(Identifier)s_methods[] = {
%(MOperationDefMethod)s
    {NULL}  /* Sentinel */
};

//
//  ------  interface object table ------
//
static PyTypeObject Py%(Identifier)s_type = {
    PyObject_HEAD_INIT ( NULL )
    0,									/* ob_size */
    "%(Module)s.%(Identifier)s",					/* tp_name */
    sizeof ( Py%(Identifier)s_object ),					/* tp_basicsize */
    0,	   			   					/* tp_itemsize */

    /* methods */
    (destructor) Py%(Identifier)s_dealloc,				/* tp_dealloc */
    0,									/* tp_print */
    0,									/* tp_getattr */
    0,									/* tp_setattr */
    0,									/* tp_compare */
    0,									/* tp_repr */
    0,									/* tp_as_number */
    0,									/* tp_as_sequence */
    0,									/* tp_as_mapping */
    0,									/* tp_hash */
    0,									/* tp_call */
    0,									/* tp_str */
    0,									/* tp_getattro */
    0,									/* tp_setattro */
    0,									/* tp_as_buffer */

    Py_TPFLAGS_DEFAULT,							/* tp_flags */

    "%(Identifier)s object",						/* tp doc */

    0,		  							/* tp_traverse */
    0,									/* tp_clear */
    0,									/* tp_richcompare */
    0,									/* tp_weaklistoffset */
    0,									/* tp_iter */
    0,									/* tp_iternext */

    Py%(Identifier)s_methods,						/* tp_methods */
    NULL,								/* tp_members */

    %(GetSetMethods)s,							/* tp_getset */
    0,									/* tp_base */
    0,									/* tp_dict */
    0,									/* tp_descr_get */
    0,									/* tp_descr_set */
    0,									/* tp_dictoffset */
    (initproc) Py%(Identifier)s_init,					/* tp_init */
    0,									/* tp_alloc */
    Py%(Identifier)s_new,						/* tp_new */
};


//
//  ------  external interface initialization hook ------
//
PyTypeObject *
%(Identifier)s_init( ) {

    if ( PyType_Ready( &Py%(Identifier)s_type ) < 0 ) {
        return NULL;
    }

    if ( ! Py%(Identifier)s_exception )
	Py%(Identifier)s_exception = PyErr_NewException("%(Identifier)s.error", NULL, NULL);

    Py_INCREF( &Py%(Identifier)s_type );
    return &Py%(Identifier)s_type;
}

%(CloseNamespace)s


