/*
 * Module code.
 *
 * Generated by SIP 4.19.25
 */
#line 134 "/build/arcus/src/libArcus-4.13.1/python/Types.sip"
#include "Types.h"
#line 9 "/build/arcus/src/libArcus-4.13.1/build/python/sipArcuspart3.cpp"

#include "sipAPIArcus.h"



static sipEnumMemberDef enummembers_SocketState[] = {
    {sipName_Closed, static_cast<int>( ::SocketState::Closed), 8},
    {sipName_Closing, static_cast<int>( ::SocketState::Closing), 8},
    {sipName_Connected, static_cast<int>( ::SocketState::Connected), 8},
    {sipName_Connecting, static_cast<int>( ::SocketState::Connecting), 8},
    {sipName_Error, static_cast<int>( ::SocketState::Error), 8},
    {sipName_Initial, static_cast<int>( ::SocketState::Initial), 8},
    {sipName_Listening, static_cast<int>( ::SocketState::Listening), 8},
    {sipName_Opening, static_cast<int>( ::SocketState::Opening), 8},
};


sipClassTypeDef sipTypeDef_Arcus_SocketState = {
    {
        -1,
        SIP_NULLPTR,
        SIP_NULLPTR,
        SIP_TYPE_SUPER_INIT|SIP_TYPE_NAMESPACE,
        sipNameNr_SocketState,
        {SIP_NULLPTR},
        SIP_NULLPTR
    },
    {
        sipNameNr_SocketState,
        {0, 0, 1},
        0, SIP_NULLPTR,
        8, enummembers_SocketState,
        0, SIP_NULLPTR,
        {SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR, SIP_NULLPTR},
    },
    SIP_NULLPTR,
    -1,
    -1,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
#if PY_MAJOR_VERSION >= 3
    SIP_NULLPTR,
    SIP_NULLPTR,
#else
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
#endif
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR,
    SIP_NULLPTR
};

#line 72 "/build/arcus/src/libArcus-4.13.1/python/Types.sip"
#include <memory>
#include "PythonMessage.h"
#line 79 "/build/arcus/src/libArcus-4.13.1/build/python/sipArcuspart3.cpp"



extern "C" {static void assign_MessagePtr(void *, SIP_SSIZE_T, void *);}
static void assign_MessagePtr(void *sipDst, SIP_SSIZE_T sipDstIdx, void *sipSrc)
{
    reinterpret_cast< ::MessagePtr *>(sipDst)[sipDstIdx] = *reinterpret_cast< ::MessagePtr *>(sipSrc);
}


extern "C" {static void *array_MessagePtr(SIP_SSIZE_T);}
static void *array_MessagePtr(SIP_SSIZE_T sipNrElem)
{
    return new  ::MessagePtr[sipNrElem];
}


extern "C" {static void *copy_MessagePtr(const void *, SIP_SSIZE_T);}
static void *copy_MessagePtr(const void *sipSrc, SIP_SSIZE_T sipSrcIdx)
{
    return new  ::MessagePtr(reinterpret_cast<const  ::MessagePtr *>(sipSrc)[sipSrcIdx]);
}


/* Call the mapped type's destructor. */
extern "C" {static void release_MessagePtr(void *, int);}
static void release_MessagePtr(void *ptr, int)
{
    Py_BEGIN_ALLOW_THREADS
    delete reinterpret_cast< ::MessagePtr *>(ptr);
    Py_END_ALLOW_THREADS
}



extern "C" {static int convertTo_MessagePtr(PyObject *, void **, int *, PyObject *);}
static int convertTo_MessagePtr(PyObject *sipPy,void **sipCppPtrV,int *sipIsErr,PyObject *sipTransferObj)
{
     ::MessagePtr **sipCppPtr = reinterpret_cast< ::MessagePtr **>(sipCppPtrV);

#line 101 "/build/arcus/src/libArcus-4.13.1/python/Types.sip"
    // Convert a Python object to a Protobuf message
    const sipTypeDef* message_type = sipFindType("PythonMessage");

    if(sipIsErr == NULL)
    {
        return sipCanConvertToType(sipPy, message_type, SIP_NOT_NONE);
    }

    if(sipCanConvertToType(sipPy, message_type, SIP_NOT_NONE))
    {
        int iserr = 0;
        int state = 0;

        PythonMessage* message = reinterpret_cast<PythonMessage*>(sipConvertToType(sipPy, message_type, NULL, 0, &state, &iserr));

        if(iserr != 0)
        {
            PyErr_SetString(PyExc_ValueError, "Could not convert to Message");
            return 0;
        }

        MessagePtr msg = message->getSharedMessage();
        *sipCppPtr = new MessagePtr(msg);

        sipReleaseType(message, message_type, state);
    }

    return sipGetState(sipTransferObj);
#line 149 "/build/arcus/src/libArcus-4.13.1/build/python/sipArcuspart3.cpp"
}


extern "C" {static PyObject *convertFrom_MessagePtr(void *, PyObject *);}
static PyObject *convertFrom_MessagePtr(void *sipCppV, PyObject *sipTransferObj)
{
    ::MessagePtr *sipCpp = reinterpret_cast< ::MessagePtr *>(sipCppV);

#line 77 "/build/arcus/src/libArcus-4.13.1/python/Types.sip"
    // Convert a Protobuf message to a Python object
    if(!(*sipCpp))
    {
        PyErr_SetString(PyExc_ValueError, "Unknown message type");
        return NULL;
    }

    const sipTypeDef* message_type = sipFindType("PythonMessage");

    PythonMessage* message = new PythonMessage(*sipCpp);

    sipTransferObj = Py_None;

    PyObject* msg = sipConvertFromType(message, message_type, sipTransferObj);
    if(!msg)
    {
        delete message;
        return NULL;
    }

    return msg;
#line 180 "/build/arcus/src/libArcus-4.13.1/build/python/sipArcuspart3.cpp"
}


sipMappedTypeDef sipTypeDef_Arcus_MessagePtr = {
    {
        -1,
        SIP_NULLPTR,
        0,
        SIP_TYPE_MAPPED,
        sipNameNr_MessagePtr,     /* MessagePtr */
        {0},
        0
    },
    {
        -1,
        {0, 0, 1},
        0, 0,
        0, 0,
        0, 0,
        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
    },
    assign_MessagePtr,
    array_MessagePtr,
    copy_MessagePtr,
    release_MessagePtr,
    convertTo_MessagePtr,
    convertFrom_MessagePtr
};
