* ./crlcore/src/crlcore:
- New: In Environment, adds a method getLIBRARYPath() to directly access the path of an element in the SearchPath. Also added to the Python interface. This is a quick alternative to fully export SearchPath and it's element into the Python interface.
This commit is contained in:
parent
c5270ec605
commit
766132a2da
|
@ -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 <cctype>
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
#include <iomanip>
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include "crlcore/Utilities.h"
|
||||
#include "crlcore/XmlParser.h"
|
||||
#include "crlcore/Environment.h"
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
#include <iomanip>
|
||||
#include <QXmlStreamReader>
|
||||
#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 "<Environment>"; }
|
||||
|
||||
|
|
|
@ -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 <regex.h>
|
||||
|
||||
#include <string>
|
||||
#include <crlcore/SearchPath.h>
|
||||
#include <regex.h>
|
||||
#include <string>
|
||||
#include <crlcore/SearchPath.h>
|
||||
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue