* All Main Python Modules:

- Change: New problem identified with the Python modules: each module seems
        to be built as a complete binary, so all the static C++ initializers are
        allocated in each module. In particular the C++ tree inheritance is built
        for *each* module so we cannot longer uses the typeid() comparisons
        across modules... It was used by boost::program_options to perform is
        casts with boost::any and was starting throwing exceptions because of
        bad casts. program_option was first initialized in "configuration"
        first included by PyViewer then in PyCRL (see Utilities.cpp).
          A first solution is to re-order the import of Python modules in
        stratus1/st_model so that CRL is imported first.
          The second is to not not link "configuration" with boost::program_option
        as only the binary vlsisapd-conf-editor needs it.
          That is a serious problem of which we must be aware and can cause further
        strange behaviors.
          Debug code used to diagnostic has been kept commented in the sources a
        it may be needed again :-(
          This behavior do not affect our singletons because they are part of
        dynamic libraries that seems to be correctly shared between the various
        Python modules.

  * ./crlcore:
    - In PyCRL, module method "getAllianceFramework()" moved as static object
        method "get()" of AllianceFramework. Object AllianceFramework added
        to module CRL.
This commit is contained in:
Jean-Paul Chaput 2010-07-17 10:22:34 +00:00
parent 3774c09bab
commit 32cd2304e9
5 changed files with 56 additions and 30 deletions

View File

@ -63,6 +63,8 @@ namespace CRL {
, _parentLibrary(NULL)
, _routingGauges()
{
//cerr << "AllianceFramework::AllianceFramework()" << endl;
// Triggers System singleton loading.
System::get ();

View File

@ -237,6 +237,23 @@ namespace CRL {
bfs::path sysConfDir ( SYS_CONF_DIR );
if ( not sysConfDir.has_root_path() ) {
if ( arguments.count("coriolis_top") ) {
// const boptions::variable_value& value = arguments["coriolis_top"];
// cerr << "value:"
// << " empty:" << boolalpha << value.empty()
// << " defaulted:" << boolalpha << value.defaulted()
// << endl;
// const type_info& info = value.value().type();
// cerr << "type_info:" << info.name()
// << " vs. " << typeid(string).name() << endl;
// cerr << "Equal:" << boolalpha << (info == typeid(std::string)) << endl;
// const type_info& info2 = typeid(string);
// cerr << (void*)&(typeid(string))
// << " vs. " << (void*)&info2
// << " vs. " << (void*)&info
// << endl;
// cerr << "any_cast<string>:" << boost::any_cast<string>(value.value()) << endl;
sysConfDir = arguments["coriolis_top"].as<string>() / sysConfDir;
} else {
cerr << Error("Environment variable CORIOLIS_TOP not set,"

View File

@ -65,6 +65,26 @@ extern "C" {
#if defined(__PYTHON_MODULE__)
static PyObject* PyAllianceFramework_get ( PyObject* )
{
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;
}
extern PyObject* PyAllianceFramework_getLibrary ( PyAllianceFramework* self, PyObject* args )
{
trace << "PyAllianceFramework_getLibrary ()" << endl;
@ -160,12 +180,18 @@ extern "C" {
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." }
{ { "get" , (PyCFunction)PyAllianceFramework_get , METH_NOARGS|METH_STATIC
, "Gets the Alliance Framework." }
, { "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 */
};
@ -182,26 +208,6 @@ extern "C" {
// 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)

View File

@ -65,9 +65,7 @@ extern "C" {
static PyMethodDef PyCRL_Methods[] =
{ { "getAllianceFramework", (PyCFunction)PyAllianceFramework_get, METH_NOARGS
, "Gets the Alliance Framework." }
, { "createPartRing" , (PyCFunction)PyToolBox_createPartRing, METH_VARARGS
{ { "createPartRing" , (PyCFunction)PyToolBox_createPartRing, METH_VARARGS
, "Partial build of a ring" }
, {NULL, NULL, 0, NULL} /* sentinel */
};
@ -103,12 +101,16 @@ extern "C" {
Py_INCREF ( &PyTypeCatalog );
PyModule_AddObject ( module, "Catalog", (PyObject*)&PyTypeCatalog );
Py_INCREF ( &PyTypeAllianceFramework );
PyModule_AddObject ( module, "AllianceFramework", (PyObject*)&PyTypeAllianceFramework );
PyCatalog_postModuleInit ();
PyObject* dictionnary = PyModule_GetDict ( module );
//DbULoadConstants ( dictionnary );
trace << "CRL.so loaded " << (void*)&typeid(string) << endl;
}

View File

@ -51,7 +51,6 @@ extern "C" {
extern PyTypeObject PyTypeAllianceFramework;
extern PyMethodDef PyAllianceFramework_Methods[];
extern PyObject* PyAllianceFramework_get ( PyObject* module );
extern PyObject* PyAllianceFramework_Link ( CRL::AllianceFramework* );
extern void PyAllianceFramework_LinkPyType ();