diff --git a/crlcore/CMakeLists.txt b/crlcore/CMakeLists.txt index 21365ec6..a64e8603 100644 --- a/crlcore/CMakeLists.txt +++ b/crlcore/CMakeLists.txt @@ -54,7 +54,14 @@ FIND_PACKAGE(HURRICANE REQUIRED) INCLUDE(UseLATEX) SET_LIB_LINK_MODE() -FIND_PACKAGE(Boost 1.33.1 COMPONENTS program_options filesystem REQUIRED) +SET(Boost_USE_STATIC_LIBS ON) +MESSAGE(STATUS "Always uses Boost static libraries.") +FIND_PACKAGE(Boost 1.35.0 COMPONENTS program_options filesystem system regex python) +IF(NOT Boost_FOUND) + FIND_PACKAGE(Boost 1.33.1 COMPONENTS program_options filesystem python regex REQUIRED) +ENDIF(NOT Boost_FOUND) +MESSAGE(STATUS "Found Boost libraries ${Boost_LIB_VERSION} in ${Boost_INCLUDE_DIR}") +MESSAGE(STATUS " ${Boost_LIBRARIES}") STRING(REGEX MATCH "^/usr" IS_USR "$ENV{CORIOLIS_TOP}") STRING(REGEX MATCH "^/opt" IS_OPT "$ENV{CORIOLIS_TOP}") diff --git a/crlcore/cmake_modules/FindCORIOLIS.cmake b/crlcore/cmake_modules/FindCORIOLIS.cmake index cb918ec2..0fa3670e 100644 --- a/crlcore/cmake_modules/FindCORIOLIS.cmake +++ b/crlcore/cmake_modules/FindCORIOLIS.cmake @@ -49,7 +49,29 @@ IF(UNIX) DOC "The ${CORIOLIS_INCLUDE_PATH_DESCRIPTION}" ) + FIND_PATH(CORIOLIS_PYTHON_INCLUDE_PATH + NAMES crlcore/PyAllianceFramework.h + PATHS ${CORIOLIS_DIR_SEARCH} + PATH_SUFFIXES include/coriolis2 include + # Help the user find it if we cannot. + DOC "${CORIOLIS_LIBRARY_PATH_DESCRIPTION}" + ) + + FIND_LIBRARY(CORIOLIS_PYTHON_LIBRARY_PATH + NAMES pycrlcore + PATHS ${CORIOLIS_DIR_SEARCH} + PATH_SUFFIXES lib${LIB_SUFFIX} + # Help the user find it if we cannot. + DOC "${CORIOLIS_LIBRARY_PATH_DESCRIPTION}" + ) + SET_LIBRARIES_PATH(CORIOLIS CRLCORE) + SET_LIBRARIES_PATH(CORIOLIS_PYTHON CORIOLIS_PYTHON) + + MESSAGE("${CORIOLIS_PYTHON_INCLUDE_PATH}") + MESSAGE("${CORIOLIS_PYTHON_LIBRARY_PATH}") + HURRICANE_CHECK_LIBRARIES(CORIOLIS) + HURRICANE_CHECK_LIBRARIES(CORIOLIS_PYTHON ${CORIOLIS_FIND_REQUIRED}) ENDIF(UNIX) diff --git a/crlcore/src/CMakeLists.txt b/crlcore/src/CMakeLists.txt index 480b55a0..6ea83480 100644 --- a/crlcore/src/CMakeLists.txt +++ b/crlcore/src/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(ccore) +add_subdirectory(pyCRL) add_subdirectory(cyclop) add_subdirectory(x2y) diff --git a/crlcore/src/ccore/CMakeLists.txt b/crlcore/src/ccore/CMakeLists.txt index 102a8821..ec4e558b 100644 --- a/crlcore/src/ccore/CMakeLists.txt +++ b/crlcore/src/ccore/CMakeLists.txt @@ -222,23 +222,37 @@ qt4_wrap_cpp ( moc_cpps ${mocincludes} ) - install ( FILES ${includes} ${mocincludes} DESTINATION include/coriolis2/crlcore ) - add_library ( crlcore ${ccore_cpps} - ${moc_cpps} - ${ap_cpps} - ${agds_cpps} - ${cif_cpps} - ${toolbox_cpps} - ${vst_parser_cpps} - ${vst_driver_cpps} - ${properties_cpps} - ${ioc_parser_cpps} - ${liberty_cpps} - ${liberty_parser_cpps} - ${bookshelf_cpps} - ${spice_cpps} - ${lefdef_cpps} - ${openaccess_cpps} + add_library ( crlcore ${ccore_cpps} + ${moc_cpps} + ${ap_cpps} + ${agds_cpps} + ${cif_cpps} + ${toolbox_cpps} + ${vst_parser_cpps} + ${vst_driver_cpps} + ${properties_cpps} + ${ioc_parser_cpps} + ${liberty_cpps} + ${liberty_parser_cpps} + ${bookshelf_cpps} + ${spice_cpps} + ${lefdef_cpps} + ${openaccess_cpps} ) - install ( TARGETS crlcore DESTINATION lib${LIB_SUFFIX} ) + target_link_libraries ( crlcore ${HURRICANE_PYTHON_LIBRARIES} + ${HURRICANE_GRAPHICAL_LIBRARIES} + ${HURRICANE_LIBRARIES} + ${CONFIGURATION_LIBRARY} + ${CIF_LIBRARY} + ${AGDS_LIBRARY} + ${LEFDEF_LIBRARIES} + ${OA_LIBRARIES} + ${QT_LIBRARIES} + ${Boost_LIBRARIES} + ${LIBXML2_LIBRARIES} + ${PYTHON_LIBRARIES} -lutil + ) + + install ( TARGETS crlcore DESTINATION lib${LIB_SUFFIX} ) + install ( FILES ${includes} ${mocincludes} DESTINATION include/coriolis2/crlcore ) diff --git a/crlcore/src/ccore/Utilities.cpp b/crlcore/src/ccore/Utilities.cpp index 0bb4bcbf..4606089b 100644 --- a/crlcore/src/ccore/Utilities.cpp +++ b/crlcore/src/ccore/Utilities.cpp @@ -206,8 +206,6 @@ namespace CRL { System::System () : _catchCore(true) { - cerr << "Creating System singleton." << endl; - // Immediate setup to avoid some tiresome looping... _singleton = this; @@ -285,8 +283,12 @@ namespace CRL { bfs::path pythonSitePackages = PYTHON_SITE_PACKAGES; pythonSitePackages = arguments["coriolis_top"].as() / pythonSitePackages; + bfs::path stratusDir = pythonSitePackages / "stratus"; + bfs::path cumulusDir = pythonSitePackages / "cumulus"; Isobar::Script::addPath ( pythonSitePackages.string() ); + Isobar::Script::addPath ( stratusDir.string() ); + Isobar::Script::addPath ( cumulusDir.string() ); // Delayed printing, as we known only now whether VerboseLevel1 is requested. if ( cmess1.enabled() ) { diff --git a/crlcore/src/cyclop/CMakeLists.txt b/crlcore/src/cyclop/CMakeLists.txt index 21a7c9c7..e274f337 100644 --- a/crlcore/src/cyclop/CMakeLists.txt +++ b/crlcore/src/cyclop/CMakeLists.txt @@ -20,20 +20,6 @@ add_executable ( cyclop ${cpps} ${MOCcpps} ) target_link_libraries ( cyclop crlcore - ${HURRICANE_PYTHON_LIBRARIES} - ${HURRICANE_GRAPHICAL_LIBRARIES} - ${HURRICANE_LIBRARIES} - ${CONFIGURATION_LIBRARY} - ${AGDS_LIBRARY} - ${CIF_LIBRARY} - ${IO_LIBRARIES} - ${OA_LIBRARIES} - ${LEFDEF_LIBRARIES} - ${QT_LIBRARIES} - ${Boost_LIBRARIES} - ${LIBXML2_LIBRARIES} - ${PYTHON_LIBRARIES} - -lutil ) install ( TARGETS cyclop DESTINATION bin ) diff --git a/crlcore/src/pyCRL/CMakeLists.txt b/crlcore/src/pyCRL/CMakeLists.txt new file mode 100644 index 00000000..2b7a27fa --- /dev/null +++ b/crlcore/src/pyCRL/CMakeLists.txt @@ -0,0 +1,52 @@ + + include_directories ( ${CRLCORE_SOURCE_DIR}/src/fonts + ${CRLCORE_SOURCE_DIR}/src/ccore + ${CRLCORE_SOURCE_DIR}/src/ccore/properties + ${CRLCORE_SOURCE_DIR}/src/ccore/bookshelf + ${CRLCORE_SOURCE_DIR}/src/ccore/cspice + ${CRLCORE_SOURCE_DIR}/src/ccore/lefdef + ${CRLCORE_SOURCE_DIR}/src/ccore/alliance/ap + ${CRLCORE_SOURCE_DIR}/src/ccore/alliance/vst + ${CRLCORE_SOURCE_DIR}/src/ccore/agds + ${CRLCORE_SOURCE_DIR}/src/ccore/cif + ${CRLCORE_SOURCE_DIR}/src/ccore/spice + ${CRLCORE_SOURCE_DIR}/src/ccore/liberty + ${CRLCORE_SOURCE_DIR}/src/ccore/toolbox + ${CRLCORE_SOURCE_DIR}/src/pyCRL + ${HURRICANE_INCLUDE_DIR} + ${CIF_INCLUDE_DIR} + ${CONFIGURATION_INCLUDE_DIR} + ${PYTHON_INCLUDE_PATH} + ) + + add_definitions ( -DCORIOLIS_TOP="${CORIOLIS_TOP}" + -DSYS_CONF_DIR="${SYS_CONF_DIR}" + -DPYTHON_SITE_PACKAGES="${PYTHON_SITE_PACKAGES}" + ) + + set ( sources PyCRL.cpp + PyCatalog.cpp + PyCatalogState.cpp + PyAllianceFramework.cpp + PyToolBox.cpp + ) + set ( includes crlcore/PyCatalog.h + crlcore/PyCatalogState.h + crlcore/PyAllianceFramework.h + crlcore/PyToolBox.h + ) + + + add_library ( pycrlcore ${sources} ) + target_link_libraries ( pycrlcore crlcore + ${HURRICANE_PYTHON_LIBRARIES} + ${PYTHON_LIBRARIES} -lutil + ) + add_library ( CRL MODULE ${sources} ) + set_target_properties ( CRL PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -D__PYTHON_MODULE__=1" + PREFIX "" + ) + + install ( FILES ${includes} DESTINATION include/coriolis2/crlcore ) + install ( TARGETS pycrlcore DESTINATION lib${LIB_SUFFIX} ) + install ( TARGETS CRL DESTINATION ${PYTHON_SITE_PACKAGES} ) diff --git a/crlcore/src/pyCRL/PyAllianceFramework.cpp b/crlcore/src/pyCRL/PyAllianceFramework.cpp new file mode 100644 index 00000000..9e5f4dc7 --- /dev/null +++ b/crlcore/src/pyCRL/PyAllianceFramework.cpp @@ -0,0 +1,217 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Module : "./PyAllianceFramework.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include "hurricane/isobar/PyCell.h" +#include "hurricane/isobar/PyLibrary.h" +#include "crlcore/Catalog.h" // TEMPORARY +#include "crlcore/PyAllianceFramework.h" + + +namespace CRL { + + using std::cerr; + using std::endl; + using std::hex; + using std::ostringstream; + using Hurricane::tab; + using Hurricane::in_trace; + using Hurricane::Error; + using Hurricane::Warning; + using Isobar::ProxyProperty; + using Isobar::ProxyError; + using Isobar::ConstructorError; + using Isobar::HurricaneError; + using Isobar::HurricaneWarning; + using Isobar::ParseOneArg; + using Isobar::ParseTwoArg; + using Isobar::PyLibrary; + using Isobar::PyLibrary_Link; + using Isobar::PyCell; + using Isobar::PyCell_Link; + + +extern "C" { + + +#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(AllianceFramework,af,function) + + +// x=================================================================x +// | "PyAllianceFramework" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + extern PyObject* PyAllianceFramework_getLibrary ( PyAllianceFramework* self, PyObject* args ) + { + trace << "PyAllianceFramework_getLibrary ()" << endl; + + Library* lib = NULL; + + HTRY + METHOD_HEAD("AllianceFramework.getLibrary()") + + PyObject* arg0; + if ( not ParseOneArg ( "AllianceFramework.getLibrary()", args, INT_ARG, &arg0 ) ) return NULL; + + lib = af->getLibrary ( PyInt_AsLong(arg0) ); + + if ( lib == NULL ) Py_RETURN_NONE; + HCATCH + + return PyLibrary_Link(lib); + } + + + extern PyObject* PyAllianceFramework_getCell ( PyAllianceFramework* self, PyObject* args ) + { + trace << "PyAllianceFramework_getCell ()" << endl; + + char* name = NULL; + Cell* cell = NULL; + int mode = 0; + + HTRY + METHOD_HEAD("AllianceFramework.getCell()") + + if ( not PyArg_ParseTuple(args,"si",&name,&mode) ) { + PyErr_SetString ( ConstructorError, "invalid number of parameters for Cell AllianceFramework.getCell()."); + return NULL; + } + + cell = af->getCell ( name, mode ); + HCATCH + + return PyCell_Link(cell); + } + + + extern PyObject* PyAllianceFramework_saveCell ( PyAllianceFramework* self, PyObject* args ) + { + trace << "PyAllianceFramework_saveCell ()" << endl; + + HTRY + + METHOD_HEAD("AllianceFramework.saveCell()") + + PyObject* arg0; + PyObject* arg1; + + if ( not ParseTwoArg ( "AllianceFramework.saveCell", args, CELL_INT_ARG, &arg0, &arg1) ) return NULL; + + af->saveCell ( PYCELL_O(arg0),PyInt_AsLong(arg1) ); + + HCATCH + + Py_RETURN_NONE; + } + + + extern PyObject* PyAllianceFramework_createCell ( PyAllianceFramework* self, PyObject* args ) + { + trace << "PyAllianceFramework_createCell ()" << endl; + + char* name = NULL; + Cell* cell = NULL; + + HTRY + METHOD_HEAD("AllianceFramework.createCell()") + + if ( not PyArg_ParseTuple(args,"s",&name) ) { + PyErr_SetString ( ConstructorError, "invalid number of parameters for Cell AllianceFramework.createCell()."); + return NULL; + } + + cell = af->createCell ( name ); + HCATCH + + return PyCell_Link(cell); + } + + + // Standart Accessors (Attributes). + + + // Standart Destroy (Attribute). + // DBoDestroyAttribute(PyAllianceFramework_destroy,PyAllianceFramework) + + + PyMethodDef PyAllianceFramework_Methods[] = + { { "getLibrary" , (PyCFunction)PyAllianceFramework_getLibrary, METH_VARARGS, "Gets a Library, by index." } + , { "getCell" , (PyCFunction)PyAllianceFramework_getCell , METH_VARARGS, "Gets an Alliance Cell." } + , { "saveCell" , (PyCFunction)PyAllianceFramework_saveCell , METH_VARARGS, "Saves an Alliance Cell." } + , { "createCell" , (PyCFunction)PyAllianceFramework_createCell, METH_VARARGS, "Create a Cell in the Alliance framework." } + //, { "destroy" , (PyCFunction)PyAllianceFramework_destroy , METH_NOARGS + // , "Destroy the associated hurricane object. The python object remains." } + , {NULL, NULL, 0, NULL} /* sentinel */ + }; + + + PythonOnlyDeleteMethod(AllianceFramework) + PyTypeObjectLinkPyType(AllianceFramework) + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyAllianceFramework" Shared Library Code Part | +// x=================================================================x + + + PyObject* PyAllianceFramework_get ( PyObject *module ) + { + trace << "PyAllianceFramework_get()" << endl; + + AllianceFramework* af = NULL; + PyAllianceFramework* pyAf = NULL; + + HTRY + af = AllianceFramework::get (); + + pyAf = PyObject_NEW ( PyAllianceFramework, &PyTypeAllianceFramework ); + if ( pyAf == NULL ) return NULL; + + pyAf->_object = af; + HCATCH + + return (PyObject*)pyAf; + } + + + + // Link/Creation Method. + PyTypeObjectDefinitions(AllianceFramework) + + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + + +} // End of CRL namespace. + diff --git a/crlcore/src/pyCRL/PyCRL.cpp b/crlcore/src/pyCRL/PyCRL.cpp new file mode 100644 index 00000000..49474a6d --- /dev/null +++ b/crlcore/src/pyCRL/PyCRL.cpp @@ -0,0 +1,121 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Module : "./PyCRL.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include "hurricane/isobar/PyHurricane.h" +#include "hurricane/isobar/PyLibrary.h" +#include "hurricane/isobar/PyCell.h" +#include "crlcore/PyCatalog.h" +#include "crlcore/PyCatalogState.h" +#include "crlcore/PyAllianceFramework.h" +#include "crlcore/PyToolBox.h" + + +namespace CRL { + + using std::cerr; + using std::endl; + using Hurricane::tab; + using Hurricane::in_trace; + using Isobar::__cs; + + +#if !defined(__PYTHON_MODULE__) + +// x=================================================================x +// | "PyCRL" Shared Library Code Part | +// x=================================================================x + + +# else // End of PyHurricane Shared Library Code Part. + + +// x=================================================================x +// | "PyCRL" Python Module Code Part | +// x=================================================================x + + +extern "C" { + + + // x-------------------------------------------------------------x + // | "PyCRL" Module Methods | + // x-------------------------------------------------------------x + + + static PyMethodDef PyCRL_Methods[] = + { { "getAllianceFramework", (PyCFunction)PyAllianceFramework_get, METH_NOARGS + , "Gets the Alliance Framework." } + , { "createPartRing" , (PyCFunction)PyToolBox_createPartRing, METH_VARARGS + , "Partial build of a ring" } + , {NULL, NULL, 0, NULL} /* sentinel */ + }; + + + + + // --------------------------------------------------------------- + // Module Initialization : "initCRL ()" + + DL_EXPORT(void) initCRL () { + trace << "initCRL()" << endl; + + PyCatalogState_LinkPyType (); + PyCatalog_LinkPyType (); + PyAllianceFramework_LinkPyType (); + + PYTYPE_READY ( CatalogState ); + PYTYPE_READY ( Catalog ); + PYTYPE_READY ( AllianceFramework ); + + // Identifier string can take up to 10 characters. + __cs.addType ( "alcFw" , &PyTypeAllianceFramework, "", false ); + __cs.addType ( "alcCatalog" , &PyTypeCatalog , "" , false ); + __cs.addType ( "alcCatStat" , &PyTypeCatalogState , "" , false ); + + PyObject* module = Py_InitModule ( "CRL", PyCRL_Methods ); + if ( module == NULL ) { + cerr << "[ERROR]\n" + << " Failed to initialize CRL module." << endl; + return; + } + + Py_INCREF ( &PyTypeCatalog ); + PyModule_AddObject ( module, "Catalog", (PyObject*)&PyTypeCatalog ); + + PyCatalog_postModuleInit (); + + PyObject* dictionnary = PyModule_GetDict ( module ); + + //DbULoadConstants ( dictionnary ); + } + + +} // End of extern "C". + + +#endif // End of Python Module Code Part. + + +} // End of CRL namespace. diff --git a/crlcore/src/pyCRL/PyCatalog.cpp b/crlcore/src/pyCRL/PyCatalog.cpp new file mode 100644 index 00000000..82fe53cb --- /dev/null +++ b/crlcore/src/pyCRL/PyCatalog.cpp @@ -0,0 +1,111 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Module : "./PyCatalog.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include "hurricane/isobar/PyCell.h" +#include "hurricane/isobar/PyLibrary.h" +#include "crlcore/Catalog.h" // TEMPORARY +#include "crlcore/PyCatalogState.h" +#include "crlcore/PyCatalog.h" + + +namespace CRL { + + using std::cerr; + using std::endl; + using std::hex; + using std::ostringstream; + using Hurricane::tab; + using Hurricane::in_trace; + using Hurricane::Error; + using Hurricane::Warning; + using Isobar::ProxyProperty; + using Isobar::ProxyError; + using Isobar::ConstructorError; + using Isobar::HurricaneError; + using Isobar::HurricaneWarning; + using Isobar::ParseOneArg; + using Isobar::ParseTwoArg; + using Isobar::PyLibrary; + using Isobar::PyLibrary_Link; + using Isobar::PyCell; + using Isobar::PyCell_Link; + + +extern "C" { + + +#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(Catalog,catalog,function) + + +// x=================================================================x +// | "PyCatalog" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + // Standart Accessors (Attributes). + + + // Standart Destroy (Attribute). + // DBoDestroyAttribute(PyCatalog_destroy,PyCatalog) + + + PyMethodDef PyCatalog_Methods[] = + { {NULL, NULL, 0, NULL} /* sentinel */ + }; + + + PythonOnlyDeleteMethod(Catalog) + PyTypeObjectLinkPyType(Catalog) + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyCatalog" Shared Library Code Part | +// x=================================================================x + + // Link/Creation Method. + PyTypeObjectDefinitions(Catalog) + + + extern void PyCatalog_postModuleInit () + { + PyCatalogState_postModuleInit (); + + PyDict_SetItemString ( PyTypeCatalog.tp_dict, "State", (PyObject*)&PyTypeCatalogState ); + } + + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + + +} // End of CRL namespace. + diff --git a/crlcore/src/pyCRL/PyCatalogState.cpp b/crlcore/src/pyCRL/PyCatalogState.cpp new file mode 100644 index 00000000..e8c33bed --- /dev/null +++ b/crlcore/src/pyCRL/PyCatalogState.cpp @@ -0,0 +1,170 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Module : "./PyCatalogState.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include "hurricane/isobar/PyCell.h" +#include "hurricane/isobar/PyLibrary.h" +#include "crlcore/Catalog.h" +#include "crlcore/PyCatalogState.h" + + +namespace CRL { + + using std::cerr; + using std::endl; + using std::hex; + using std::ostringstream; + using Hurricane::tab; + using Hurricane::in_trace; + using Hurricane::Error; + using Hurricane::Warning; + using Isobar::ProxyProperty; + using Isobar::ProxyError; + using Isobar::ConstructorError; + using Isobar::HurricaneError; + using Isobar::HurricaneWarning; + using Isobar::ParseOneArg; + using Isobar::ParseTwoArg; + using Isobar::PyLibrary; + using Isobar::PyLibrary_Link; + using Isobar::PyCell; + using Isobar::PyCell_Link; + + +extern "C" { + + +#define METHOD_HEAD(function) GENERIC_METHOD_HEAD(CatalogState,state,function) + + +// x=================================================================x +// | "PyCatalogState" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + + // Standart Accessors (Attributes). + DirectGetBoolAttribute(PyCatalogState_isFlattenLeaf,isFlattenLeaf,PyCatalogState,Catalog::State) + DirectGetBoolAttribute(PyCatalogState_isFeed ,isFeed ,PyCatalogState,Catalog::State) + DirectGetBoolAttribute(PyCatalogState_isGds ,isGds ,PyCatalogState,Catalog::State) + DirectGetBoolAttribute(PyCatalogState_isDelete ,isDelete ,PyCatalogState,Catalog::State) + DirectGetBoolAttribute(PyCatalogState_isPhysical ,isPhysical ,PyCatalogState,Catalog::State) + DirectGetBoolAttribute(PyCatalogState_isLogical ,isFlattenLeaf,PyCatalogState,Catalog::State) + + DirectSetBoolAttribute(PyCatalogState_setFlattenLeaf,setFlattenLeaf,"Catalog::State::setFlatenLeaf",PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setFeed ,setFeed ,"Catalog::State::setFeed" ,PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setGds ,setGds ,"Catalog::State::setGds" ,PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setDelete ,setDelete ,"Catalog::State::setDelete" ,PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setPhysical ,setPhysical ,"Catalog::State::setPhysical" ,PyCatalogState,Catalog::State) + DirectSetBoolAttribute(PyCatalogState_setLogical ,setFlattenLeaf,"Catalog::State::setLogical" ,PyCatalogState,Catalog::State) + + + // Standart Destroy (Attribute). + // DBoDestroyAttribute(PyCatalogState_destroy,PyCatalog) + + + PyMethodDef PyCatalogState_Methods[] = + { { "isFlattenLeaf" , (PyCFunction)PyCatalogState_isFlattenLeaf, METH_NOARGS + , "Return true if the Cell must not be explored for hierarchy." } + , { "isFeed" , (PyCFunction)PyCatalogState_isFeed, METH_NOARGS + , "Return true if the Cell is a feed through." } + , { "isGds" , (PyCFunction)PyCatalogState_isGds, METH_NOARGS + , "Return true if the Cell is a GDSII import." } + , { "isDelete" , (PyCFunction)PyCatalogState_isDelete, METH_NOARGS + , "Return true if the Cell has the Catalog Delete attribute." } + , { "isPhysical" , (PyCFunction)PyCatalogState_isPhysical, METH_NOARGS + , "Return true if the Cell possesses a physical (layout) view." } + , { "isLogical" , (PyCFunction)PyCatalogState_isLogical, METH_NOARGS + , "Return true if the Cell possesses a logical (netlist) view." } + , { "setFlattenLeaf", (PyCFunction)PyCatalogState_setFlattenLeaf, METH_VARARGS + , "Sets/reset the FlattenLeaf flag of a Cell." } + , { "setFeed" , (PyCFunction)PyCatalogState_setFeed, METH_VARARGS + , "Sets/reset the Feed flag of a Cell." } + , { "setGds" , (PyCFunction)PyCatalogState_setGds, METH_VARARGS + , "Sets/reset the Gds flag of a Cell." } + , { "setDelete" , (PyCFunction)PyCatalogState_setDelete, METH_VARARGS + , "Sets/reset the Delete flag of a Cell." } + , { "setPhysical" , (PyCFunction)PyCatalogState_setPhysical, METH_VARARGS + , "Sets/reset the Pysical flag of a Cell." } + , { "setLogical" , (PyCFunction)PyCatalogState_setLogical, METH_VARARGS + , "Sets/reset the Logical flag of a Cell." } + , {NULL, NULL, 0, NULL} /* sentinel */ + }; + + + PythonOnlyDeleteMethod(CatalogState) + + DirectReprMethod(PyCatalogState_Repr, PyCatalogState, Catalog::State) + DirectStrMethod (PyCatalogState_Str, PyCatalogState, Catalog::State) + DirectCmpMethod (PyCatalogState_Cmp, IsPyCatalogState, PyCatalogState) + DirectHashMethod(PyCatalogState_Hash, PyCatalogState) + + extern void PyCatalogState_LinkPyType() { + trace << "PyCatalogState_LinkType()" << endl; + PyTypeCatalogState.tp_dealloc = (destructor) PyCatalogState_DeAlloc; + PyTypeCatalogState.tp_compare = (cmpfunc) PyCatalogState_Cmp; + PyTypeCatalogState.tp_repr = (reprfunc) PyCatalogState_Repr; + PyTypeCatalogState.tp_str = (reprfunc) PyCatalogState_Str; + PyTypeCatalogState.tp_hash = (hashfunc) PyCatalogState_Hash; + PyTypeCatalogState.tp_methods = PyCatalogState_Methods; + } + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyCatalogState" Shared Library Code Part | +// x=================================================================x + + + extern void PyCatalogState_postModuleInit () + { + PyObject* constant; + + LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::FlattenLeaf,"FlattenLeaf"); + LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Feed ,"Feed"); + LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::GDS ,"GDS"); + LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Delete ,"Delete"); + LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Logical ,"Logical"); + LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Physical ,"Physical"); + LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::InMemory ,"InMemory"); + LoadObjectConstant(PyTypeCatalogState.tp_dict,Catalog::State::Views ,"Views"); + } + + + + // Link/Creation Method. + PyTypeObjectDefinitions(CatalogState) + + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + + +} // End of CRL namespace. + diff --git a/crlcore/src/pyCRL/PyToolBox.cpp b/crlcore/src/pyCRL/PyToolBox.cpp new file mode 100644 index 00000000..6ef322b0 --- /dev/null +++ b/crlcore/src/pyCRL/PyToolBox.cpp @@ -0,0 +1,94 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Module : "./PyToolBox.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#include "hurricane/isobar/PyCell.h" +#include "crlcore/ToolBox.h" +#include "crlcore/PyToolBox.h" + + +namespace CRL { + + using std::cerr; + using std::endl; + using std::hex; + using std::ostringstream; + using Hurricane::tab; + using Hurricane::in_trace; + using Hurricane::Error; + using Hurricane::Warning; + using Isobar::ProxyProperty; + using Isobar::ProxyError; + using Isobar::ConstructorError; + using Isobar::HurricaneError; + using Isobar::HurricaneWarning; + using Isobar::ParseOneArg; + using Isobar::ParseTwoArg; + using Isobar::PyCell; + using Isobar::PyCell_Link; + + +extern "C" { + + +// x=================================================================x +// | "PyToolBox" Python Module Code Part | +// x=================================================================x + +#if defined(__PYTHON_MODULE__) + + +#else // End of Python Module Code Part. + + +// x=================================================================x +// | "PyToolBox" Shared Library Code Part | +// x=================================================================x + + + extern PyObject* PyToolBox_createPartRing ( PyObject* module, PyObject* args ) + { + trace << "PyToolBox_createPartRing ()" << endl; + + HTRY + PyObject* arg0; + PyObject* arg1; + + if ( not ParseTwoArg ( "CRL.createPartRing", args, CELL_STRING_ARG, &arg0, &arg1 ) ) + return NULL; + + createPartRing ( PYCELL_O(arg0), PyString_AsString(arg1) ); + HCATCH + + Py_RETURN_NONE; + } + + +#endif // End of Shared Library Code Part. + + +} // End of extern "C". + + +} // End of CRL namespace. diff --git a/crlcore/src/pyCRL/crlcore/PyAllianceFramework.h b/crlcore/src/pyCRL/crlcore/PyAllianceFramework.h new file mode 100644 index 00000000..5135e95a --- /dev/null +++ b/crlcore/src/pyCRL/crlcore/PyAllianceFramework.h @@ -0,0 +1,70 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Header : "./PyAllianceFramework.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#ifndef __PY_ALLIANCE_FRAMEWORK__ +#define __PY_ALLIANCE_FRAMEWORK__ + +#include "hurricane/isobar/PyHurricane.h" +#include "crlcore/AllianceFramework.h" + + +namespace CRL { + + +extern "C" { + + +// ------------------------------------------------------------------- +// Python Object : "PyAllianceFramework". + + typedef struct { + PyObject_HEAD + CRL::AllianceFramework* _object; + } PyAllianceFramework; + + +// ------------------------------------------------------------------- +// Functions & Types exported to "PyCRL.ccp". + + extern PyTypeObject PyTypeAllianceFramework; + extern PyMethodDef PyAllianceFramework_Methods[]; + + extern PyObject* PyAllianceFramework_get ( PyObject* module ); + extern PyObject* PyAllianceFramework_Link ( CRL::AllianceFramework* ); + extern void PyAllianceFramework_LinkPyType (); + + +#define IsPyAllianceFramework(v) ( (v)->ob_type == &PyTypeAllianceFramework ) +#define PYALLIANCEFRAMEWORK(v) ( (PyAllianceFramework*)(v) ) +#define PYALLIANCEFRAMEWORK_O(v) ( PYALLIANCEFRAMEWORK(v)->_object ) + + +} // End of extern "C". + + +} // End of CRL namespace. + + +#endif // __PY_ALLIANCE_FRAMEWORK__ diff --git a/crlcore/src/pyCRL/crlcore/PyCatalog.h b/crlcore/src/pyCRL/crlcore/PyCatalog.h new file mode 100644 index 00000000..82018c16 --- /dev/null +++ b/crlcore/src/pyCRL/crlcore/PyCatalog.h @@ -0,0 +1,70 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Header : "./PyCatalog.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#ifndef __PY_CRL_CATALOG__ +#define __PY_CRL_CATALOG__ + +#include "hurricane/isobar/PyHurricane.h" +#include "crlcore/Catalog.h" + + +namespace CRL { + + +extern "C" { + + +// ------------------------------------------------------------------- +// Python Object : "PyCatalog". + + typedef struct { + PyObject_HEAD + CRL::Catalog* _object; + } PyCatalog; + + +// ------------------------------------------------------------------- +// Functions & Types exported to "PyCRL.ccp". + + extern PyTypeObject PyTypeCatalog; + extern PyMethodDef PyCatalog_Methods[]; + + extern PyObject* PyCatalog_Link ( CRL::Catalog* ); + extern void PyCatalog_LinkPyType (); + extern void PyCatalog_postModuleInit (); + + +#define IsPyCatalog(v) ( (v)->ob_type == &PyTypeCatalog ) +#define PYCATALOG(v) ( (PyCatalog*)(v) ) +#define PYCATALOG_O(v) ( PYCATALOG(v)->_object ) + + +} // End of extern "C". + + +} // End of CRL namespace. + + +#endif // __PY_CRL_CATALOG__ diff --git a/crlcore/src/pyCRL/crlcore/PyCatalogState.h b/crlcore/src/pyCRL/crlcore/PyCatalogState.h new file mode 100644 index 00000000..cc285ea0 --- /dev/null +++ b/crlcore/src/pyCRL/crlcore/PyCatalogState.h @@ -0,0 +1,70 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Header : "./PyCatalogState.cpp" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#ifndef __PY_CRL_CATALOG_STATE__ +#define __PY_CRL_CATALOG_STATE__ + +#include "hurricane/isobar/PyHurricane.h" +#include "crlcore/Catalog.h" + + +namespace CRL { + + +extern "C" { + + +// ------------------------------------------------------------------- +// Python Object : "PyCatalogState". + + typedef struct { + PyObject_HEAD + CRL::Catalog::State* _object; + } PyCatalogState; + + +// ------------------------------------------------------------------- +// Functions & Types exported to "PyCRL.ccp". + + extern PyTypeObject PyTypeCatalogState; + extern PyMethodDef PyCatalogState_Methods[]; + + extern PyObject* PyCatalogState_Link ( CRL::Catalog::State* ); + extern void PyCatalogState_LinkPyType (); + extern void PyCatalogState_postModuleInit (); + + +#define IsPyCatalogState(v) ( (v)->ob_type == &PyTypeCatalogState ) +#define PYCATALOGSTATE(v) ( (PyCatalogState*)(v) ) +#define PYCATALOGSTATE_O(v) ( PYCATALOGSTATE(v)->_object ) + + +} // End of extern "C". + + +} // End of CRL namespace. + + +#endif // __PY_CRL_CATALOG_STATE__ diff --git a/crlcore/src/pyCRL/crlcore/PyToolBox.h b/crlcore/src/pyCRL/crlcore/PyToolBox.h new file mode 100644 index 00000000..ccceaaa0 --- /dev/null +++ b/crlcore/src/pyCRL/crlcore/PyToolBox.h @@ -0,0 +1,50 @@ + +// -*- C++ -*- +// +// This file is part of the Coriolis Software. +// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved +// +// =================================================================== +// +// $Id$ +// +// x-----------------------------------------------------------------x +// | | +// | C O R I O L I S | +// | Alliance / Hurricane Interface | +// | | +// | Author : Jean-Paul CHAPUT | +// | E-mail : Jean-Paul.Chaput@asim.lip6.fr | +// | =============================================================== | +// | C++ Header : "./PyToolBox.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + + +#ifndef __PY_CRL_TOOLBOX__ +#define __PY_CRL_TOOLBOX__ + +#include "hurricane/isobar/PyHurricane.h" + + +namespace CRL { + + +extern "C" { + + +// ------------------------------------------------------------------- +// Functions & Types exported to "PyCRL.ccp". + + extern PyObject* PyToolBox_createPartRing ( PyObject* module, PyObject* args ); + + +} // End of extern "C". + + +} // End of CRL namespace. + + +#endif // __PY_CRL_TOOLBOX__ diff --git a/crlcore/src/x2y/CMakeLists.txt b/crlcore/src/x2y/CMakeLists.txt index be9b0695..1277d054 100644 --- a/crlcore/src/x2y/CMakeLists.txt +++ b/crlcore/src/x2y/CMakeLists.txt @@ -10,19 +10,5 @@ link_directories ( ${CRLCORE_BINARY_DIR}/src/ccore ) add_executable ( cx2y ${cpps} ) - target_link_libraries ( cx2y crlcore - ${HURRICANE_PYTHON_LIBRARIES} - ${HURRICANE_GRAPHICAL_LIBRARIES} - ${HURRICANE_LIBRARIES} - ${CONFIGURATION_LIBRARY} - ${AGDS_LIBRARY} - ${CIF_LIBRARY} - ${OA_LIBRARIES} - ${QT_LIBRARIES} - ${LEFDEF_LIBRARIES} - ${Boost_LIBRARIES} - ${LIBXML2_LIBRARIES} - ${PYTHON_LIBRARIES} - -lutil - ) + target_link_libraries ( cx2y crlcore ) install ( TARGETS cx2y DESTINATION bin )