Skip to content

Commit

Permalink
Refs #4399. Switch to boost::python::type_info
Browse files Browse the repository at this point in the history
This is more reliable on all platforms.
  • Loading branch information
martyngigg committed Feb 16, 2012
1 parent b762c20 commit d5785e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions Code/Mantid/Framework/PythonInterface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ set ( PYTEST_HELPERS test/python/testhelpers.py )

# python unit tests
if (PYUNITTEST_FOUND)
if ( UNIX )
pyunittest_add_test ( VanillaPythonInterfaceTest.py ${TEST_PY_FILES} )
# Helpers
set ( VANILLA_TEST_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/VanillaPythonInterfaceTest )
Expand All @@ -131,7 +130,6 @@ if (PYUNITTEST_FOUND)
add_dependencies ( FrameworkTests VanillaPythonInterfaceTest.py )
# Add to the 'UnitTests' group in VS
set_property ( TARGET VanillaPythonInterfaceTest.py PROPERTY FOLDER "UnitTests" )
endif()
endif ()

###########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Includes
//-----------------------------------------------------------------------------
#include "MantidPythonInterface/kernel/Registry/TypeRegistry.h"
//#include "MantidPythonInterface/kernel/PropertyWithValue.h"
#include "MantidPythonInterface/kernel/Registry/RegisterSingleValueHandler.h"
#include "MantidPythonInterface/kernel/Registry/SequenceTypeHandler.h"

#include "MantidKernel/Property.h" // provides getUnmangledTypeName
#include <map>
#include <boost/python/type_id.hpp>

namespace Mantid
{
Expand All @@ -18,7 +18,7 @@ namespace Mantid
namespace // <anonymous>
{
/// Typedef the map of type_info -> handler objects
typedef std::map<const std::type_info*, PropertyValueHandler*> TypeIDMap;
typedef std::map<const boost::python::type_info, PropertyValueHandler*> TypeIDMap;

/**
* Returns a reference to the static type map
Expand All @@ -43,6 +43,7 @@ namespace Mantid
REGISTER_SINGLEVALUE_HANDLER(uint32_t);
REGISTER_SINGLEVALUE_HANDLER(int64_t);
REGISTER_SINGLEVALUE_HANDLER(uint64_t);
REGISTER_SINGLEVALUE_HANDLER(unsigned int);
REGISTER_SINGLEVALUE_HANDLER(bool);
REGISTER_SINGLEVALUE_HANDLER(double);
REGISTER_SINGLEVALUE_HANDLER(std::string);
Expand Down Expand Up @@ -72,7 +73,7 @@ namespace Mantid
void registerHandler(const std::type_info& typeObject, PropertyValueHandler* handler)
{
TypeIDMap & typeHandlers = typeRegistry();
typeHandlers.insert(std::make_pair(&typeObject, handler));
typeHandlers.insert(std::make_pair(boost::python::type_info(typeObject), handler));
}

/**
Expand All @@ -83,7 +84,7 @@ namespace Mantid
PropertyValueHandler *getHandler(const std::type_info& typeObject)
{
TypeIDMap & typeHandlers = typeRegistry();
TypeIDMap::const_iterator itr = typeHandlers.find(&typeObject);
TypeIDMap::const_iterator itr = typeHandlers.find(boost::python::type_info(typeObject));
if( itr == typeHandlers.end() )
{
throw std::invalid_argument("No handler registered for property type '" + Kernel::getUnmangledTypeName(typeObject) + "'");
Expand Down

0 comments on commit d5785e5

Please sign in to comment.