Mac/clang: make cfg parameters use key type std::string rather than const std::string
This commit is contained in:
parent
aa0494a2d5
commit
c7d564fbb6
|
@ -78,7 +78,7 @@ namespace Cfg {
|
||||||
|
|
||||||
Parameter* Configuration::getParameter ( string name, Parameter::Type type ) const
|
Parameter* Configuration::getParameter ( string name, Parameter::Type type ) const
|
||||||
{
|
{
|
||||||
map<const string,Parameter*>::const_iterator iparameter = _parameters.find(name);
|
map<string,Parameter*>::const_iterator iparameter = _parameters.find(name);
|
||||||
if ( iparameter == _parameters.end() ) return NULL;
|
if ( iparameter == _parameters.end() ) return NULL;
|
||||||
|
|
||||||
if ( type != Parameter::Unknown ) {
|
if ( type != Parameter::Unknown ) {
|
||||||
|
|
|
@ -172,8 +172,8 @@ namespace Cfg {
|
||||||
|
|
||||||
void ConfigurationWidget::syncSlaves ()
|
void ConfigurationWidget::syncSlaves ()
|
||||||
{
|
{
|
||||||
const map<const string,Parameter*>& parameters = Configuration::get()->getParameters ();
|
const map<string,Parameter*>& parameters = Configuration::get()->getParameters ();
|
||||||
map<const string,Parameter*>::const_iterator iparam = parameters.begin();
|
map<string,Parameter*>::const_iterator iparam = parameters.begin();
|
||||||
|
|
||||||
for ( ; iparam != parameters.end() ; ++iparam ) {
|
for ( ; iparam != parameters.end() ; ++iparam ) {
|
||||||
if ( (*iparam).second->getSlaves().empty() ) continue;
|
if ( (*iparam).second->getSlaves().empty() ) continue;
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Cfg {
|
||||||
// Methods.
|
// Methods.
|
||||||
ConfigurationWidget* buildWidget ( unsigned int flags );
|
ConfigurationWidget* buildWidget ( unsigned int flags );
|
||||||
ConfigurationDialog* buildDialog ();
|
ConfigurationDialog* buildDialog ();
|
||||||
inline const std::map<const std::string,Parameter*>&
|
inline const std::map<std::string,Parameter*>&
|
||||||
getParameters () const;
|
getParameters () const;
|
||||||
const std::set<LogEntry>& getLogs ( unsigned int ilog ) const;
|
const std::set<LogEntry>& getLogs ( unsigned int ilog ) const;
|
||||||
inline unsigned int getFlags () const;
|
inline unsigned int getFlags () const;
|
||||||
|
@ -80,7 +80,7 @@ namespace Cfg {
|
||||||
private:
|
private:
|
||||||
// Attributes.
|
// Attributes.
|
||||||
static Configuration* _singleton;
|
static Configuration* _singleton;
|
||||||
std::map<const std::string,Parameter*> _parameters;
|
std::map<std::string,Parameter*> _parameters;
|
||||||
LayoutDescription _layout;
|
LayoutDescription _layout;
|
||||||
unsigned int _flags;
|
unsigned int _flags;
|
||||||
std::map< unsigned int, std::set<LogEntry> > _logSets;
|
std::map< unsigned int, std::set<LogEntry> > _logSets;
|
||||||
|
@ -90,7 +90,7 @@ namespace Cfg {
|
||||||
|
|
||||||
|
|
||||||
// Inline Methods.
|
// Inline Methods.
|
||||||
inline const std::map<const std::string,Parameter*>& Configuration::getParameters () const
|
inline const std::map<std::string,Parameter*>& Configuration::getParameters () const
|
||||||
{ return _parameters; }
|
{ return _parameters; }
|
||||||
|
|
||||||
inline const LayoutDescription& Configuration::getLayout () const { return _layout; }
|
inline const LayoutDescription& Configuration::getLayout () const { return _layout; }
|
||||||
|
|
|
@ -117,10 +117,10 @@ namespace Isobar3 {
|
||||||
string elementName = ::Hurricane::demangle(typeid(CppT));
|
string elementName = ::Hurricane::demangle(typeid(CppT));
|
||||||
size_t cppScope = elementName.find_last_of( "::" );
|
size_t cppScope = elementName.find_last_of( "::" );
|
||||||
if (cppScope != std::string::npos) elementName = elementName.substr( cppScope+1 );
|
if (cppScope != std::string::npos) elementName = elementName.substr( cppScope+1 );
|
||||||
|
cerr << "elementName: " << elementName <<endl;
|
||||||
string keyName = ::Hurricane::demangle(typeid(CppK));
|
string keyName = ::Hurricane::demangle(typeid(CppK));
|
||||||
cppScope = keyName.find_last_of( "::" );
|
cppScope = keyName.find_last_of( "::" );
|
||||||
if (cppScope != std::string::npos) keyName = keyName.substr( cppScope+1 );
|
if (cppScope != std::string::npos) keyName = keyName.substr( cppScope+1 );
|
||||||
|
|
||||||
manager->_setTypeNames( "MapIteratorOf" + elementName + "By" + keyName );
|
manager->_setTypeNames( "MapIteratorOf" + elementName + "By" + keyName );
|
||||||
manager->_setupPyType();
|
manager->_setupPyType();
|
||||||
PyTypeObject* ob_type = manager->_getTypeObject();
|
PyTypeObject* ob_type = manager->_getTypeObject();
|
||||||
|
@ -218,6 +218,9 @@ namespace Isobar3 {
|
||||||
template< typename CppK, typename CppT >
|
template< typename CppK, typename CppT >
|
||||||
PyObject* PyTypeManagerMap<CppK,CppT>::_getMpSubscript ( PyObject* self, PyObject* pyKey )
|
PyObject* PyTypeManagerMap<CppK,CppT>::_getMpSubscript ( PyObject* self, PyObject* pyKey )
|
||||||
{
|
{
|
||||||
|
std::cerr << "PyTypeManagerMap<CppK,CppT>::_getMpSubscript" << endl;
|
||||||
|
std::cerr << "CppK: " << demangle(typeid(CppK)) << std::endl;
|
||||||
|
std::cerr << "CppT: " << demangle(typeid(CppT)) << std::endl;
|
||||||
std::map<CppK,CppT>* pmap = NULL;
|
std::map<CppK,CppT>* pmap = NULL;
|
||||||
if (not pyToC(self,&pmap)) {
|
if (not pyToC(self,&pmap)) {
|
||||||
std::string message = "PyTypeManagerMap<CppK,CppT>::_getMpSubscript(): pyToC<> failed. \".";
|
std::string message = "PyTypeManagerMap<CppK,CppT>::_getMpSubscript(): pyToC<> failed. \".";
|
||||||
|
@ -225,6 +228,7 @@ namespace Isobar3 {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
CppK key;
|
CppK key;
|
||||||
|
std::cerr << "extracting key, type: " << demangle(typeid(CppK)) << std::endl;
|
||||||
if (not pyToC( pyKey, &key )) {
|
if (not pyToC( pyKey, &key )) {
|
||||||
std::string message = "PyTypeManagerMap<CppK,CppT>::_getMpSubscript(): Unable to convert key.";
|
std::string message = "PyTypeManagerMap<CppK,CppT>::_getMpSubscript(): Unable to convert key.";
|
||||||
PyErr_SetString( HurricaneError, message.c_str() );
|
PyErr_SetString( HurricaneError, message.c_str() );
|
||||||
|
@ -262,8 +266,11 @@ namespace Isobar3 {
|
||||||
template< typename CppK, typename CppT >
|
template< typename CppK, typename CppT >
|
||||||
PyTypeManagerMap<CppK,CppT>* PyTypeManagerMap<CppK,CppT>::create ( PyObject* module, uint64_t flags )
|
PyTypeManagerMap<CppK,CppT>* PyTypeManagerMap<CppK,CppT>::create ( PyObject* module, uint64_t flags )
|
||||||
{
|
{
|
||||||
// cerr << "PyTypeManagerMap<"
|
cerr << "PyTypeManagerMap<"
|
||||||
// << ::Hurricane::demangle(typeid(std::map<CppK,CppT>)) << ">::create()" << endl;
|
<< ::Hurricane::demangle(typeid(std::map<CppK,CppT>)) << ">::create()" << endl;
|
||||||
|
|
||||||
|
cerr << "CppK: " << demangle(typeid(CppK)) << endl <<" CppT: " << demangle(typeid(CppT)) << endl;
|
||||||
|
|
||||||
PyTypeManagerMap<CppK,CppT>* manager = new PyTypeManagerMap<CppK,CppT>( flags );
|
PyTypeManagerMap<CppK,CppT>* manager = new PyTypeManagerMap<CppK,CppT>( flags );
|
||||||
|
|
||||||
string elementName = ::Hurricane::demangle(typeid(CppT));
|
string elementName = ::Hurricane::demangle(typeid(CppT));
|
||||||
|
@ -280,6 +287,7 @@ namespace Isobar3 {
|
||||||
ob_type->tp_as_mapping = &(manager->_mappingMethods);
|
ob_type->tp_as_mapping = &(manager->_mappingMethods);
|
||||||
ob_type->tp_iter = (getiterfunc)&::Isobar3::_tpIter;
|
ob_type->tp_iter = (getiterfunc)&::Isobar3::_tpIter;
|
||||||
|
|
||||||
|
PyTypeManager::add<CppK>( module, manager );
|
||||||
PyTypeManager::add< std::map<CppK,CppT> >( module, manager );
|
PyTypeManager::add< std::map<CppK,CppT> >( module, manager );
|
||||||
PyTypeManagerMapIterator<CppK,CppT>::create( module, flags );
|
PyTypeManagerMapIterator<CppK,CppT>::create( module, flags );
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,7 @@ extern "C" {
|
||||||
if (element == _managerByPyTypes.end())
|
if (element == _managerByPyTypes.end())
|
||||||
throw Error( "PyTypeManager::get(PyTypeObject*): Unregistered type <%s>."
|
throw Error( "PyTypeManager::get(PyTypeObject*): Unregistered type <%s>."
|
||||||
, obType->tp_name );
|
, obType->tp_name );
|
||||||
|
//std::cerr << "returning element "<< (*element) << " second " << (*element).second << std::endl;
|
||||||
return (*element).second;
|
return (*element).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,12 +435,12 @@ extern "C" {
|
||||||
template< typename CppT >
|
template< typename CppT >
|
||||||
inline PyObject* PyTypeManager::link ( CppT* object )
|
inline PyObject* PyTypeManager::link ( CppT* object )
|
||||||
{
|
{
|
||||||
// std::cerr << "PyTypeManager<CppT>::link() " << demangle(typeid(CppT).name())
|
std::cerr << "PyTypeManager<CppT>::link() " << demangle(typeid(CppT).name())
|
||||||
// << "* object = " << (void*)object << ":" << object << std::endl;
|
<< "* object = " << (void*)object << ":" << object << std::endl;
|
||||||
if (not object) Py_RETURN_NONE;
|
if (not object) Py_RETURN_NONE;
|
||||||
PyTypeManagerVTrunk<CppT>* manager = dynamic_cast< PyTypeManagerVTrunk<CppT>* >( _get<CppT>() );
|
PyTypeManagerVTrunk<CppT>* manager = dynamic_cast< PyTypeManagerVTrunk<CppT>* >( _get<CppT>() );
|
||||||
// std::cerr << "_get<CppT>()=" << _get<CppT>() << endl;
|
std::cerr << "_get<CppT>()=" << _get<CppT>() << endl;
|
||||||
// std::cerr << demangle(typeid(PyTypeManagerVTrunk<CppT>*).name()) << endl;
|
std::cerr << demangle(typeid(PyTypeManagerVTrunk<CppT>*).name()) << endl;
|
||||||
if (not manager)
|
if (not manager)
|
||||||
throw Error( "PyTypeManager<CppT>::link(): No manager for type <%s>."
|
throw Error( "PyTypeManager<CppT>::link(): No manager for type <%s>."
|
||||||
, demangle(typeid(CppT).name()).c_str() );
|
, demangle(typeid(CppT).name()).c_str() );
|
||||||
|
@ -1577,11 +1578,13 @@ namespace Isobar3 {
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Standard Python to C types converters.
|
// Standard Python to C types converters.
|
||||||
|
|
||||||
|
using Hurricane::demangle;
|
||||||
|
|
||||||
template< typename T
|
template< typename T
|
||||||
, typename std::enable_if< !std::is_pointer<T>::value, bool >::type = true >
|
, typename std::enable_if< !std::is_pointer<T>::value, bool >::type = true >
|
||||||
inline bool pyToC ( PyObject* pyArg, T* arg )
|
inline bool pyToC ( PyObject* pyArg, T* arg )
|
||||||
{
|
{
|
||||||
|
std::cerr << "template< typename T , typename std::enable_if< !std::is_pointer<T>::value, bool >::type = true > pyToC( PyObject* pyArg, T* arg ) " << " T = " << demangle(typeid(T).name()) <<std::endl;
|
||||||
typedef typename std::remove_cv<T>::type NonConstT;
|
typedef typename std::remove_cv<T>::type NonConstT;
|
||||||
Isobar3::PyTypeManager* manager = Isobar3::PyTypeManager::_get<T>();
|
Isobar3::PyTypeManager* manager = Isobar3::PyTypeManager::_get<T>();
|
||||||
if (not manager) {
|
if (not manager) {
|
||||||
|
@ -1597,13 +1600,16 @@ inline bool pyToC ( PyObject* pyArg, T* arg )
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool pyToC ( PyObject* pyArg, T** arg )
|
inline bool pyToC ( PyObject* pyArg, T** arg )
|
||||||
{
|
{
|
||||||
|
std::cerr << "template<typename T> pyToC( PyObject* pyArg, T** arg ) " << " T = " << demangle(typeid(T).name()) <<std::endl;
|
||||||
|
|
||||||
Isobar3::PyTypeManager* manager = Isobar3::PyTypeManager::_get<T>();
|
Isobar3::PyTypeManager* manager = Isobar3::PyTypeManager::_get<T>();
|
||||||
if (not manager) {
|
if (not manager) {
|
||||||
std::cerr << "Isobar3::pyToC<T>(T*&): Unsupported type \"" << typeid(T).name() << "\"" << std::endl;
|
std::cerr << "Isobar3::pyToC<T>(T*&): Unsupported type \"" << demangle(typeid(T).name()) << "\"" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// std::cerr << "pyToC< " << demangle(typeid(T).name()) << " >() called." << std::endl;
|
std::cerr << "pyToC< " << demangle(typeid(T).name()) << " >() called." << std::endl;
|
||||||
*arg = (T*)( Isobar3::object1( pyArg ));
|
*arg = (T*)( Isobar3::object1( pyArg ));
|
||||||
|
std::cerr << "returning "<<std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1701,12 +1707,12 @@ namespace Isobar3 {
|
||||||
const std::string nth[] = { "First", "Second" , "Third", "Fourth", "Fifth"
|
const std::string nth[] = { "First", "Second" , "Third", "Fourth", "Fifth"
|
||||||
, "Sixth", "Seventh", "Eight", "Ninth" , "Tenth" };
|
, "Sixth", "Seventh", "Eight", "Ninth" , "Tenth" };
|
||||||
|
|
||||||
//std::cerr << "Calling pyToC<" << demangle(typeid(typename Arg<T>::ValueT).name()) << ">" << std::endl;
|
std::cerr << "Calling pyToC<" << demangle(typeid(typename Arg<T>::ValueT).name()) << ">" << std::endl;
|
||||||
//std::cerr << "Calling pyToC<" << demangle(typeid(&(as<T>( args[count]))).name()) << ">" << std::endl;
|
std::cerr << "Calling pyToC<" << demangle(typeid(&(as<T>( args[count]))).name()) << ">" << std::endl;
|
||||||
//success = success and pyToC< typename Arg<T>::ValueT >( pyArgs[count]
|
//success = success and pyToC< typename Arg<T>::ValueT >( pyArgs[count]
|
||||||
// , &(as<T>( args[count])) );
|
// , &(as<T>( args[count])) );
|
||||||
success = success and pyToC( pyArgs[count], &(as<T>( args[count])) );
|
success = success and pyToC( pyArgs[count], &(as<T>( args[count])) );
|
||||||
//std::cerr << "success=" << success << std::endl;
|
std::cerr << "success=" << success << std::endl;
|
||||||
if (not success) {
|
if (not success) {
|
||||||
message += "\n " + getString(nth) + " X argument is not convertible to \"" + Hurricane::demangle(typeid(T).name()) + "\".";
|
message += "\n " + getString(nth) + " X argument is not convertible to \"" + Hurricane::demangle(typeid(T).name()) + "\".";
|
||||||
PyErr_SetString( Isobar3::ConstructorError, message.c_str() );
|
PyErr_SetString( Isobar3::ConstructorError, message.c_str() );
|
||||||
|
|
Loading…
Reference in New Issue