diff --git a/crlcore/src/ccore/Environment.cpp b/crlcore/src/ccore/Environment.cpp index 8ab70b96..cf1fa55d 100644 --- a/crlcore/src/ccore/Environment.cpp +++ b/crlcore/src/ccore/Environment.cpp @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved +// Copyright (c) UPMC 2008-2013, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | @@ -15,16 +15,14 @@ // +-----------------------------------------------------------------+ -#include -#include -#include -#include - -#include - -#include "crlcore/Utilities.h" -#include "crlcore/XmlParser.h" -#include "crlcore/Environment.h" +#include +#include +#include +#include +#include +#include "crlcore/Utilities.h" +#include "crlcore/XmlParser.h" +#include "crlcore/Environment.h" namespace { @@ -750,6 +748,13 @@ namespace CRL { } + string Environment::getLIBRARYPath ( size_t i ) + { + if (i >= _LIBRARIES.getSize()) return ""; + return _LIBRARIES[i].getPath(); + } + + string Environment::_getString () const { return ""; } diff --git a/crlcore/src/ccore/crlcore/Environment.h b/crlcore/src/ccore/crlcore/Environment.h index 5ae1f350..3af3149d 100644 --- a/crlcore/src/ccore/crlcore/Environment.h +++ b/crlcore/src/ccore/crlcore/Environment.h @@ -2,7 +2,7 @@ // -*- C++ -*- // // This file is part of the Coriolis Software. -// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved +// Copyright (c) UPMC 2008-2013, All Rights Reserved // // +-----------------------------------------------------------------+ // | C O R I O L I S | @@ -15,13 +15,12 @@ // +-----------------------------------------------------------------+ -#ifndef __CRL_ENVIRONMENT__ -#define __CRL_ENVIRONMENT__ +#ifndef CRL_ENVIRONMENT +#define CRL_ENVIRONMENT -#include - -#include -#include +#include +#include +#include namespace CRL { @@ -30,14 +29,12 @@ namespace CRL { class Environment { public: enum AddMode { Append=1, Prepend=2, Replace=3 }; - public: // Internal: Static Methods. static const char* getEnv ( const char* variable, const char* defaultValue ); // Constructors & destructors. Environment (); ~Environment (); - // Accessors. inline const std::string& getCORIOLIS_TOP () const; inline const std::string& getDisplayStyle () const; @@ -56,14 +53,13 @@ namespace CRL { inline const std::string& getPad () const; inline const std::string& getCATALOG () const; inline SearchPath& getLIBRARIES (); - + std::string getLIBRARYPath ( size_t i ); // Predicates. bool isPOWER ( const char* name ) const; bool isGROUND ( const char* name ) const; bool isCLOCK ( const char* name ) const; bool isBLOCKAGE ( const char* name ) const; bool isPad ( const char* name ) const; - // Modifiers. void validate () const; void loadFromXml ( const std::string& path="", bool warnNotFound=true ); @@ -85,13 +81,11 @@ namespace CRL { inline void setCATALOG ( const char* value ); inline void setWORKING_LIBRARY ( const char* value ); void addSYSTEM_LIBRARY ( const char* value, const char* libName, unsigned int mode=Append ); - // Methods. std::string getPrint () const; inline std::string _getTypeName () const; std::string _getString () const; Record* _getRecord () const; - protected: // Internal: Attributes. std::string _CORIOLIS_TOP; @@ -117,7 +111,6 @@ namespace CRL { regex_t _BlockageRegex; regex_t _padRegex; bool _inConstructor; - private: void _setRegex ( regex_t* regex, const std::string& pattern, const char* name ); }; @@ -156,10 +149,10 @@ namespace CRL { inline std::string Environment::_getTypeName () const { return "Environment"; } -} // End of CRL namespace. +} // CRL namespace. INSPECTOR_P_SUPPORT(CRL::Environment); -# endif +#endif diff --git a/crlcore/src/pyCRL/PyEnvironment.cpp b/crlcore/src/pyCRL/PyEnvironment.cpp index 44d16e97..7f49f641 100644 --- a/crlcore/src/pyCRL/PyEnvironment.cpp +++ b/crlcore/src/pyCRL/PyEnvironment.cpp @@ -154,6 +154,27 @@ extern "C" { } + PyObject* PyEnvironment_getLIBRARYPath ( PyEnvironment* self, PyObject* args ) + { + trace << "PyEnvironment_getLIBRARYPath()" << endl; + + HTRY + METHOD_HEAD("Environment.getLIBRARYPath()") + int index = 0; + + if (PyArg_ParseTuple( args, "i:Environment.addLIBRARYPath", &index )) { + string path = env->getLIBRARYPath( index ); + if (path.size()) return Py_BuildValue( "s", path.c_str() ); + } else { + PyErr_SetString( ConstructorError, "invalid number of parameters for Environment.getLIBRARYPath." ); + return NULL; + } + HCATCH + + Py_RETURN_NONE; + } + + static PyObject* PyEnvironment_Repr ( PyEnvironment* self ) { if ( self->ACCESS_OBJECT == NULL ) @@ -245,6 +266,8 @@ extern "C" { , "Gets the pad cell recognition regular expression." } , { "getCATALOG" , (PyCFunction)PyEnvironment_getCATALOG , METH_NOARGS , "Gets the catalog file name." } + , { "getLIBRARYPath" , (PyCFunction)PyEnvironment_getLIBRARYPath , METH_VARARGS + , "Gets the path of the library at the given index." } , { "getPrint" , (PyCFunction)PyEnvironment_getPrint , METH_NOARGS , "Display the environment in a terminal fashion formating." } , { "isPOWER" , (PyCFunction)PyEnvironment_isPOWER , METH_VARARGS