From c86d074f0691b28eef73e7f2d4e175e79b10e7c5 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sat, 14 Jan 2023 12:05:51 +0100 Subject: [PATCH] Export Contact::setLayer() to the Python interface. --- hurricane/src/isobar/PyContact.cpp | 23 +++++++++++++++++++ .../src/isobar/hurricane/isobar/PyContact.h | 6 +---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/hurricane/src/isobar/PyContact.cpp b/hurricane/src/isobar/PyContact.cpp index 1c039188..14e6cc1c 100644 --- a/hurricane/src/isobar/PyContact.cpp +++ b/hurricane/src/isobar/PyContact.cpp @@ -138,6 +138,28 @@ extern "C" { } + static PyObject* PyContact_setLayer ( PyContact* self, PyObject* args ) + { + cdebug_log(30,0) << "PyContact_setLayer()" << endl; + HTRY + METHOD_HEAD("Contact.setLayer()") + PyObject* pyLayer = NULL; + if (PyArg_ParseTuple( args, "O:Contact.setLayer", &pyLayer)) { + if (IsPyDerivedLayer(pyLayer)) { + contact->setLayer( PYDERIVEDLAYER_O( pyLayer )); + } else { + PyErr_SetString ( ConstructorError, "invalid parameter type for Contact.setLayer()." ); + return NULL; + } + } else { + PyErr_SetString ( ConstructorError, "Invalid number of parameters passed to Contact.setLayer()." ); + return NULL; + } + HCATCH + Py_RETURN_NONE; + } + + PyMethodDef PyContact_Methods[] = { { "create" , (PyCFunction)PyContact_create , METH_VARARGS|METH_STATIC , "Create a new Contact." } @@ -158,6 +180,7 @@ extern "C" { , { "setDy" , (PyCFunction)PyContact_setDy , METH_VARARGS, "Sets the contact dy value." } , { "setWidth" , (PyCFunction)PyContact_setWidth , METH_VARARGS, "Sets the contact width." } , { "setHeight" , (PyCFunction)PyContact_setHeight , METH_VARARGS, "Sets the contact height." } + , { "setLayer" , (PyCFunction)PyContact_setLayer , METH_VARARGS, "Sets the contact layer." } , {NULL, NULL, 0, NULL} /* sentinel */ }; diff --git a/hurricane/src/isobar/hurricane/isobar/PyContact.h b/hurricane/src/isobar/hurricane/isobar/PyContact.h index 964a2f6d..bfbce6e2 100644 --- a/hurricane/src/isobar/hurricane/isobar/PyContact.h +++ b/hurricane/src/isobar/hurricane/isobar/PyContact.h @@ -14,9 +14,7 @@ // +-----------------------------------------------------------------+ -#ifndef PY_CONTACT_H -#define PY_CONTACT_H - +#pragma once #include "hurricane/isobar/PyComponent.h" #include "hurricane/Contact.h" @@ -51,5 +49,3 @@ namespace Isobar { } // extern "C". } // Isobar namespace. - -#endif // PY_CONTACT_H