Mac/clang: make cfg parameters use key type std::string rather than const std::string

This commit is contained in:
Rob Taylor 2023-09-19 10:40:58 +01:00
parent aa0494a2d5
commit c7d564fbb6
5 changed files with 32 additions and 18 deletions

View File

@ -78,7 +78,7 @@ namespace Cfg {
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 ( type != Parameter::Unknown ) {

View File

@ -172,8 +172,8 @@ namespace Cfg {
void ConfigurationWidget::syncSlaves ()
{
const map<const string,Parameter*>& parameters = Configuration::get()->getParameters ();
map<const string,Parameter*>::const_iterator iparam = parameters.begin();
const map<string,Parameter*>& parameters = Configuration::get()->getParameters ();
map<string,Parameter*>::const_iterator iparam = parameters.begin();
for ( ; iparam != parameters.end() ; ++iparam ) {
if ( (*iparam).second->getSlaves().empty() ) continue;

View File

@ -55,7 +55,7 @@ namespace Cfg {
// Methods.
ConfigurationWidget* buildWidget ( unsigned int flags );
ConfigurationDialog* buildDialog ();
inline const std::map<const std::string,Parameter*>&
inline const std::map<std::string,Parameter*>&
getParameters () const;
const std::set<LogEntry>& getLogs ( unsigned int ilog ) const;
inline unsigned int getFlags () const;
@ -80,7 +80,7 @@ namespace Cfg {
private:
// Attributes.
static Configuration* _singleton;
std::map<const std::string,Parameter*> _parameters;
std::map<std::string,Parameter*> _parameters;
LayoutDescription _layout;
unsigned int _flags;
std::map< unsigned int, std::set<LogEntry> > _logSets;
@ -90,7 +90,7 @@ namespace Cfg {
// 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; }
inline const LayoutDescription& Configuration::getLayout () const { return _layout; }

View File

@ -117,10 +117,10 @@ namespace Isobar3 {
string elementName = ::Hurricane::demangle(typeid(CppT));
size_t cppScope = elementName.find_last_of( "::" );
if (cppScope != std::string::npos) elementName = elementName.substr( cppScope+1 );
cerr << "elementName: " << elementName <<endl;
string keyName = ::Hurricane::demangle(typeid(CppK));
cppScope = keyName.find_last_of( "::" );
if (cppScope != std::string::npos) keyName = keyName.substr( cppScope+1 );
manager->_setTypeNames( "MapIteratorOf" + elementName + "By" + keyName );
manager->_setupPyType();
PyTypeObject* ob_type = manager->_getTypeObject();
@ -218,6 +218,9 @@ namespace Isobar3 {
template< typename CppK, typename CppT >
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;
if (not pyToC(self,&pmap)) {
std::string message = "PyTypeManagerMap<CppK,CppT>::_getMpSubscript(): pyToC<> failed. \".";
@ -225,6 +228,7 @@ namespace Isobar3 {
return NULL;
}
CppK key;
std::cerr << "extracting key, type: " << demangle(typeid(CppK)) << std::endl;
if (not pyToC( pyKey, &key )) {
std::string message = "PyTypeManagerMap<CppK,CppT>::_getMpSubscript(): Unable to convert key.";
PyErr_SetString( HurricaneError, message.c_str() );
@ -262,8 +266,11 @@ namespace Isobar3 {
template< typename CppK, typename CppT >
PyTypeManagerMap<CppK,CppT>* PyTypeManagerMap<CppK,CppT>::create ( PyObject* module, uint64_t flags )
{
// cerr << "PyTypeManagerMap<"
// << ::Hurricane::demangle(typeid(std::map<CppK,CppT>)) << ">::create()" << endl;
cerr << "PyTypeManagerMap<"
<< ::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 );
string elementName = ::Hurricane::demangle(typeid(CppT));
@ -280,6 +287,7 @@ namespace Isobar3 {
ob_type->tp_as_mapping = &(manager->_mappingMethods);
ob_type->tp_iter = (getiterfunc)&::Isobar3::_tpIter;
PyTypeManager::add<CppK>( module, manager );
PyTypeManager::add< std::map<CppK,CppT> >( module, manager );
PyTypeManagerMapIterator<CppK,CppT>::create( module, flags );

View File

@ -264,6 +264,7 @@ extern "C" {
if (element == _managerByPyTypes.end())
throw Error( "PyTypeManager::get(PyTypeObject*): Unregistered type <%s>."
, obType->tp_name );
//std::cerr << "returning element "<< (*element) << " second " << (*element).second << std::endl;
return (*element).second;
}
@ -434,12 +435,12 @@ extern "C" {
template< typename CppT >
inline PyObject* PyTypeManager::link ( CppT* object )
{
// std::cerr << "PyTypeManager<CppT>::link() " << demangle(typeid(CppT).name())
// << "* object = " << (void*)object << ":" << object << std::endl;
std::cerr << "PyTypeManager<CppT>::link() " << demangle(typeid(CppT).name())
<< "* object = " << (void*)object << ":" << object << std::endl;
if (not object) Py_RETURN_NONE;
PyTypeManagerVTrunk<CppT>* manager = dynamic_cast< PyTypeManagerVTrunk<CppT>* >( _get<CppT>() );
// std::cerr << "_get<CppT>()=" << _get<CppT>() << endl;
// std::cerr << demangle(typeid(PyTypeManagerVTrunk<CppT>*).name()) << endl;
std::cerr << "_get<CppT>()=" << _get<CppT>() << endl;
std::cerr << demangle(typeid(PyTypeManagerVTrunk<CppT>*).name()) << endl;
if (not manager)
throw Error( "PyTypeManager<CppT>::link(): No manager for type <%s>."
, demangle(typeid(CppT).name()).c_str() );
@ -1577,11 +1578,13 @@ namespace Isobar3 {
// -------------------------------------------------------------------
// Standard Python to C types converters.
using Hurricane::demangle;
template< typename T
, typename std::enable_if< !std::is_pointer<T>::value, bool >::type = true >
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;
Isobar3::PyTypeManager* manager = Isobar3::PyTypeManager::_get<T>();
if (not manager) {
@ -1597,13 +1600,16 @@ inline bool pyToC ( PyObject* pyArg, T* arg )
template<typename T>
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>();
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;
}
// 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 ));
std::cerr << "returning "<<std::endl;
return true;
}
@ -1701,12 +1707,12 @@ namespace Isobar3 {
const std::string nth[] = { "First", "Second" , "Third", "Fourth", "Fifth"
, "Sixth", "Seventh", "Eight", "Ninth" , "Tenth" };
//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(typename Arg<T>::ValueT).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]
// , &(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) {
message += "\n " + getString(nth) + " X argument is not convertible to \"" + Hurricane::demangle(typeid(T).name()) + "\".";
PyErr_SetString( Isobar3::ConstructorError, message.c_str() );