From 07b51b10c773b08ce370839d54d5ee7ea6f57bf9 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Wed, 17 Feb 2021 23:20:24 +0100 Subject: [PATCH] Allow to demote Net external component to "internal", export to Python. --- .../src/hurricane/NetExternalComponents.cpp | 4 ++++ .../hurricane/NetExternalComponents.h | 7 ++---- .../src/isobar/PyNetExternalComponents.cpp | 22 +++++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/hurricane/src/hurricane/NetExternalComponents.cpp b/hurricane/src/hurricane/NetExternalComponents.cpp index b89be898..f6a2547c 100644 --- a/hurricane/src/hurricane/NetExternalComponents.cpp +++ b/hurricane/src/hurricane/NetExternalComponents.cpp @@ -67,6 +67,10 @@ namespace Hurricane { } + void NetExternalComponents::setInternal ( Component* component ) + { component->removeProperty( _name ); } + + void NetExternalComponents::setExternal ( Component* component ) { Net* net = component->getNet(); diff --git a/hurricane/src/hurricane/hurricane/NetExternalComponents.h b/hurricane/src/hurricane/hurricane/NetExternalComponents.h index bca291a3..fa5ebea4 100644 --- a/hurricane/src/hurricane/hurricane/NetExternalComponents.h +++ b/hurricane/src/hurricane/hurricane/NetExternalComponents.h @@ -29,9 +29,7 @@ // +-----------------------------------------------------------------+ -#ifndef HURRICANE_NET_EXTERNAL_COMPONENTS_H -#define HURRICANE_NET_EXTERNAL_COMPONENTS_H - +#pragma once #include "hurricane/Component.h" #include "hurricane/Relation.h" @@ -44,6 +42,7 @@ namespace Hurricane { class NetExternalComponents { public: static Components get ( const Net* ); + static void setInternal ( Component* ); static void setExternal ( Component* ); static bool isExternal ( Component* ); static void toJson ( JsonWriter*, const Net* ); @@ -69,5 +68,3 @@ namespace Hurricane { } // Hurricane namespace. - -#endif // HURRICANE_NET_EXTERNAL_COMPONENTS_H diff --git a/hurricane/src/isobar/PyNetExternalComponents.cpp b/hurricane/src/isobar/PyNetExternalComponents.cpp index 69c0da22..23d7179d 100644 --- a/hurricane/src/isobar/PyNetExternalComponents.cpp +++ b/hurricane/src/isobar/PyNetExternalComponents.cpp @@ -61,6 +61,26 @@ extern "C" { } + static PyObject* PyNetInternalComponents_setInternal ( PyObject*, PyObject *args ) + { + cdebug_log(20,0) << "PyNetInternalComponents_setInternal()" << endl; + HTRY + PyObject* pyComponent; + if (PyArg_ParseTuple( args, "O", &pyComponent )) { + if (not PyObject_IsInstance(pyComponent,(PyObject*)&PyTypeComponent)) { + PyErr_SetString( ConstructorError, "NetInternalComponents.setInternal(): First argument is not of type Component." ); + return NULL; + } + NetExternalComponents::setInternal( PYCOMPONENT_O(pyComponent) ); + } else { + PyErr_SetString( ConstructorError, "Bad parameters given to NetInternalComponents.setInternal()." ); + return NULL; + } + HCATCH + Py_RETURN_NONE; + } + + static PyObject* PyNetExternalComponents_setExternal ( PyObject*, PyObject *args ) { cdebug_log(20,0) << "PyNetExternalComponents_setExternal()" << endl; @@ -110,6 +130,8 @@ extern "C" { PyMethodDef PyNetExternalComponents_Methods[] = { { "isExternal" , (PyCFunction)PyNetExternalComponents_isExternal , METH_VARARGS|METH_CLASS , "Tells if Component belong to the externals of the Net." } + , { "setInternal", (PyCFunction)PyNetInternalComponents_setInternal, METH_VARARGS|METH_CLASS + , "Remove the Component from the external part of it's Net." } , { "setExternal", (PyCFunction)PyNetExternalComponents_setExternal, METH_VARARGS|METH_CLASS , "Flag the Component as belonging to to the external part of it's Net." } , { "get" , (PyCFunction)PyNetExternalComponents_get , METH_VARARGS|METH_CLASS