Improve error messages about parameters in PyOccurrence constructor.

This commit is contained in:
Jean-Paul Chaput 2018-03-18 23:29:57 +01:00
parent 1c2c858ce8
commit 2a36a72e34
1 changed files with 24 additions and 22 deletions

View File

@ -61,42 +61,44 @@ extern "C" {
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Attribute Method : "PyOccurrence_NEW ()" // Attribute Method : "PyOccurrence_NEW ()"
PyObject* PyOccurrence_NEW ( PyObject *module, PyObject *args ) { PyObject* PyOccurrence_NEW ( PyObject *module, PyObject *args )
{
cdebug_log(20,0) << "PyOccurrence_NEW()" << endl; cdebug_log(20,0) << "PyOccurrence_NEW()" << endl;
Occurrence* occurrence; Occurrence* occurrence;
PyObject* arg0; PyObject* arg0;
PyObject* arg1; PyObject* arg1;
__cs.init ("Occurrence.Occurrence"); __cs.init( "Occurrence.Occurrence" );
if ( ! PyArg_ParseTuple(args,"|O&O&:Occurrence.Occurrence" if (not PyArg_ParseTuple( args,"|O&O&:Occurrence.Occurrence"
,Converter,&arg0 , Converter, &arg0
,Converter,&arg1 , Converter, &arg1
)) { )) {
PyErr_SetString ( ConstructorError, "invalid number of parameters for Occurrence constructor. " ); PyErr_SetString( ConstructorError, "More than two parameters given to Occurrence constructor." );
return NULL; return NULL;
} }
PyOccurrence* pyOccurrence = NULL; PyOccurrence* pyOccurrence = NULL;
HTRY HTRY
if ( __cs.getObjectIds() == NO_ARG ) { occurrence = new Occurrence (); } if ( (__cs.getObjectIds() == ENT_ARG )
else if ( __cs.getObjectIds() == ENT_ARG ) { occurrence = new Occurrence ( PYENTITY_O(arg0) ); } or (__cs.getObjectIds() == COMP_ARG ) ) { occurrence = new Occurrence ( EntityCast(arg0) ); }
else if ( __cs.getObjectIds() == COMP_PATH_ARG) { occurrence = new Occurrence ( PYSEGMENT_O(arg0) else if (__cs.getObjectIds() == NO_ARG ) { occurrence = new Occurrence (); }
, *PYPATH_O(arg1) ); } else if (__cs.getObjectIds() == COMP_PATH_ARG) { occurrence = new Occurrence ( EntityCast(arg0)
else if ( __cs.getObjectIds() == ENT_PATH_ARG ) { occurrence = new Occurrence ( PYENTITY_O(arg0) , *PYPATH_O(arg1) ); }
, *PYPATH_O(arg1) ); } else if (__cs.getObjectIds() == ENT_PATH_ARG ) { occurrence = new Occurrence ( EntityCast(arg0)
else { , *PYPATH_O(arg1) ); }
PyErr_SetString ( ConstructorError, "invalid number of parameters for Occurrence constructor. " ); else {
return ( NULL ); PyErr_SetString( ConstructorError, "Bad type(s) of parameters given to Occurrence constructor." );
} return NULL;
}
pyOccurrence = PyObject_NEW(PyOccurrence, &PyTypeOccurrence);
if (pyOccurrence == NULL) return NULL; pyOccurrence = PyObject_NEW( PyOccurrence, &PyTypeOccurrence );
if (pyOccurrence == NULL) return NULL;
pyOccurrence->_object = occurrence;
pyOccurrence->_object = occurrence;
HCATCH HCATCH
return ( (PyObject*)pyOccurrence ); return (PyObject*)pyOccurrence;
} }