// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // %ExportedHeaderCode #include %End %MappedType NCollection_Sequence { %TypeHeaderCode #include %End %ConvertFromTypeCode // Create the list. PyObject *l; if ((l = PyList_New(sipCpp->Length())) == NULL) return NULL; // Set the list elements. for (int i = 1; i <= sipCpp->Length(); ++i) { HYDROData_Entity* aPntr = createPointer(sipCpp->Value(i)); PyObject *tobj; if ((tobj = sipConvertFromNewType(aPntr, sipFindType( aPntr->DynamicType()->Name() ), sipTransferObj)) == NULL) { Py_DECREF(l); { Handle_HYDROData_Entity anEnt( aPntr ); } return NULL; } PyList_SET_ITEM(l, i - 1, tobj); } return l; %End %ConvertToTypeCode SIP_SSIZE_T len; // Check the type if that is all that is required. if (sipIsErr == NULL) { if (!PySequence_Check(sipPy) || (len = PySequence_Size(sipPy)) < 0) return 0; for (SIP_SSIZE_T i = 0; i < len; ++i) { PyObject *itm = PySequence_ITEM(sipPy, i); bool ok = (itm && sipCanConvertToType(itm, sipType_HYDROData_Entity, SIP_NOT_NONE)); Py_XDECREF(itm); if (!ok) return 0; } return 1; } NCollection_Sequence *aSeq = new NCollection_Sequence; len = PySequence_Size(sipPy); for (SIP_SSIZE_T i = 0; i < len; ++i) { PyObject *itm = PySequence_ITEM(sipPy, i); int state; HYDROData_Entity *t = reinterpret_cast(sipConvertToType(itm, sipType_HYDROData_Entity, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr)); Py_DECREF(itm); if (*sipIsErr) { sipReleaseType(t, sipType_HYDROData_Entity, state); delete aSeq; return 0; } Handle_HYDROData_Entity anEnt( t ); aSeq->Append( anEnt ); //sipReleaseType(t, sipType_HYDROData_Entity, state); } *sipCppPtr = aSeq; return sipGetState(sipTransferObj); %End }; typedef NCollection_Sequence HYDROData_SequenceOfObjects;