|
Boost-Commit : |
From: oryol_at_[hidden]
Date: 2008-02-14 12:51:42
Author: jeremypack
Date: 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
New Revision: 43249
URL: http://svn.boost.org/trac/boost/changeset/43249
Log:
Typeinfo changes - first performance improvements
Removed:
sandbox/boost/reflection/impl/
Text files modified:
sandbox/boost/extension/impl/typeinfo.hpp | 100 ++++++++++++++++++++-------------------
sandbox/boost/reflection/parameter_map.hpp | 12 ++--
sandbox/boost/reflection/reflection.hpp | 6 +
sandbox/boost/reflection/reflector.hpp | 3
sandbox/boost/reflection/static_reflection.hpp | 6 +-
sandbox/libs/extension/examples/registry/registry_example.cpp | 4
sandbox/libs/extension/test/hello_world_test.cpp | 2
sandbox/libs/extension/test/lib_caching_test.cpp | 22 ++------
sandbox/libs/extension/test/registry_test.cpp | 8 +-
sandbox/libs/reflection/doc/reflection.qbk | 4
sandbox/libs/reflection/doc/tutorials.qbk | 12 ++--
sandbox/libs/reflection/examples/extension/extension.cpp | 21 ++++----
12 files changed, 98 insertions(+), 102 deletions(-)
Modified: sandbox/boost/extension/impl/typeinfo.hpp
==============================================================================
--- sandbox/boost/extension/impl/typeinfo.hpp (original)
+++ sandbox/boost/extension/impl/typeinfo.hpp 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -13,66 +13,68 @@
#ifndef BOOST_EXTENSION_TYPEINFO_HPP
#define BOOST_EXTENSION_TYPEINFO_HPP
-namespace boost{namespace extensions{
+#include <typeinfo>
+namespace boost { namespace extensions {
template <class TypeInfo, class ClassType>
struct type_info_handler
{
static TypeInfo get_class_type();
};
-}}
-#ifndef BOOST_EXTENSION_USER_TYPE_INFO_CUSTOM
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
- // For DLLs
-# define BOOST_EXTENSION_EXTERNAL extern "C" __declspec(dllexport)
-#include <string>
-#include <typeinfo>
-namespace boost{namespace extensions{
- typedef std::string default_type_info;
- template <class ClassType>
- struct type_info_handler<default_type_info, ClassType>
- {
- static default_type_info get_class_type(){return typeid(ClassType).name();}
- };
-}}
-#else
-#ifdef __APPLE__
-#include <typeinfo>
-#include <string>
-/*namespace boost{namespace extensions{
- typedef basic_factory_map<std::type_info> factory_map;
- template <>
- std::type_info basic_factory_map<std::string>::get_class_type()
- {
- return typeid(ClassType);
+class default_type_info {
+public:
+ default_type_info(const std::type_info& new_type) : type(new_type) {
+ }
+ const std::type_info& type;
+};
+template <class ClassType>
+struct type_info_handler<default_type_info, ClassType>
+{
+ static default_type_info get_class_type(){
+ return default_type_info(typeid(ClassType));
}
-}}*/
-namespace boost{namespace extensions{
- typedef std::string default_type_info;
- template <class ClassType>
- struct type_info_handler<default_type_info, ClassType>
- {
- static default_type_info get_class_type(){return typeid(ClassType).name();}
- };
+};
}}
+
+// This list should be expanded to all platforms that successfully
+// compare type_info across shared library boundaries.
+#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || \
+defined(__APPLE__) || defined(BOOST_EXTENSION_FORCE_FAST_TYPEINFO)
+namespace boost { namespace extensions {
+bool operator<(const default_type_info& first,
+ const default_type_info& second) {
+ return first.type.name() < second.type.name();
+}
+
+bool operator==(const default_type_info& first,
+ const default_type_info& second) {
+ return first.type.name() == second.type.name();
+}
+
+bool operator>(const default_type_info& first,
+ const default_type_info& second) {
+ return first.type.name() > second.type.name();
+}
+}}
#else
#include <string>
-#include <typeinfo>
-namespace boost{namespace extensions{
- typedef std::string default_type_info;
- template <class ClassType>
- struct type_info_handler<default_type_info, ClassType>
- {
- static default_type_info get_class_type(){return typeid(ClassType).name();}
- };
-}}
+namespace boost { namespace extensions {
+bool operator<(const default_type_info& first,
+ const default_type_info& second) {
+ return first.type.name() < second.type.name();
+}
-#endif //Apple
-#endif //Windows
-#endif // BOOST_EXTENSION_USER_TYPE_INFO_CUSTOM
-#ifndef BOOST_EXTENSION_EXTERNAL
-# define BOOST_EXTENSION_EXTERNAL extern "C"
-#endif
+bool operator==(const default_type_info& first,
+ const default_type_info& second) {
+ return first.type.name() == second.type.name();
+}
+bool operator>(const default_type_info& first,
+ const default_type_info& second) {
+ return first.type.name() > second.type.name();
+}
+}}
#endif
+
+#endif // BOOST_EXTENSION_TYPEINFO_HPP
Modified: sandbox/boost/reflection/parameter_map.hpp
==============================================================================
--- sandbox/boost/reflection/parameter_map.hpp (original)
+++ sandbox/boost/reflection/parameter_map.hpp 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -12,11 +12,13 @@
#ifndef BOOST_REFLECTION_PARAMETER_MAP_HPP
#define BOOST_REFLECTION_PARAMETER_MAP_HPP
-#include <boost/reflection/impl/typeinfo.hpp>
+#include <boost/extension/impl/typeinfo.hpp>
#include <exception>
#include <map>
#include <vector>
namespace boost { namespace reflections {
+using extensions::type_info_handler;
+
class conversion_not_found_exception : public std::exception {
public:
virtual const char* what() {
@@ -24,7 +26,7 @@
}
};
typedef void (*FunctionPtr)();
-template <class TypeInfo = reflections::default_type_info>
+template <class TypeInfo = extensions::default_type_info>
class generic_parameter {
public:
virtual ~generic_parameter() {
@@ -73,7 +75,7 @@
void* value_;
};
-template <class T, class TypeInfo = reflections::default_type_info>
+template <class T, class TypeInfo = extensions::default_type_info>
class parameter : public generic_parameter<TypeInfo> {
public:
template <class A, class B>
@@ -87,7 +89,7 @@
value_(value) {
// Add converter for current type.
generic_parameter<TypeInfo>::converters_.insert
- (make_pair(reflections::type_info_handler<TypeInfo, T>::get_class_type(),
+ (std::make_pair(reflections::type_info_handler<TypeInfo, T>::get_class_type(),
new default_converter<T>()));
}
template <class S>
@@ -136,7 +138,7 @@
};
template <class Info = std::string,
- class TypeInfo = default_type_info>
+ class TypeInfo = extensions::default_type_info>
class basic_parameter_map
: public std::multimap<Info, generic_parameter<TypeInfo>*> {
public:
Modified: sandbox/boost/reflection/reflection.hpp
==============================================================================
--- sandbox/boost/reflection/reflection.hpp (original)
+++ sandbox/boost/reflection/reflection.hpp 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -14,13 +14,15 @@
#include <map>
#include <vector>
-#include <boost/reflection/impl/typeinfo.hpp>
+#include <boost/extension/impl/typeinfo.hpp>
#include <boost/reflection/constructor.hpp>
#include <boost/reflection/factory.hpp>
#include <boost/reflection/function.hpp>
// #include <boost/reflection/parameter_map.hpp>
namespace boost {namespace reflections {
+using extensions::type_info_handler;
+
#define BOOST_REFLECTION_REFLECTION_GET_CONSTRUCTOR_FUNCTION(Z, N, _) \
template <class ParamFirst BOOST_PP_COMMA_IF(N) \
BOOST_PP_ENUM_PARAMS(N, class Param)> \
@@ -178,7 +180,7 @@
};
template <class Info = std::string, class ParameterInfo = void,
- class TypeInfo = reflections::default_type_info>
+ class TypeInfo = extensions::default_type_info>
class basic_reflection
{
public:
Modified: sandbox/boost/reflection/reflector.hpp
==============================================================================
--- sandbox/boost/reflection/reflector.hpp (original)
+++ sandbox/boost/reflection/reflector.hpp 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -19,6 +19,7 @@
namespace boost {namespace reflections {
+using extensions::type_info_handler;
#define BOOST_REFLECTION_REFLECTOR_REFLECT_CONSTRUCTOR_FUNCTION(Z, N, _) \
template <class ParamFirst BOOST_PP_COMMA_IF(N) \
@@ -176,7 +177,7 @@
template <class T, class Info = std::string, class ParameterInfo = void,
- class TypeInfo = reflections::default_type_info>
+ class TypeInfo = extensions::default_type_info>
class reflector
{
public:
Modified: sandbox/boost/reflection/static_reflection.hpp
==============================================================================
--- sandbox/boost/reflection/static_reflection.hpp (original)
+++ sandbox/boost/reflection/static_reflection.hpp 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -13,11 +13,11 @@
#ifndef BOOST_REFLECTION_STATIC_REFLECTION_HPP
#define BOOST_REFLECTION_STATIC_REFLECTION_HPP
#include <map>
+#include <boost/extension/impl/typeinfo.hpp>
#include <boost/reflection/factory.hpp>
-#include <boost/reflection/impl/typeinfo.hpp>
namespace boost { namespace reflections {
-
+using extensions::type_info_handler;
#define BOOST_REFLECTION_FACTORY_MAP_GET_FUNCTION(Z, N, _) \
template <class Info, class ReturnValue \
BOOST_PP_COMMA_IF(N) \
@@ -107,7 +107,7 @@
};
std::map<TypeInfo, generic_map_holder*> maps_;
};
-typedef basic_static_reflection<default_type_info> static_reflection;
+typedef basic_static_reflection<extensions::default_type_info> static_reflection;
}}
#undef BOOST_REFLECTION_STATIC_REFLECTION_GET_FUNCTION
Modified: sandbox/libs/extension/examples/registry/registry_example.cpp
==============================================================================
--- sandbox/libs/extension/examples/registry/registry_example.cpp (original)
+++ sandbox/libs/extension/examples/registry/registry_example.cpp 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -17,7 +17,7 @@
int main(int argc, char * argv[])
{
registry reg;
- reg.open("../bin/libRegistryLibrary.extension");
+ reg.open("libRegistryLibrary.extension");
{
std::list<counted_factory<word, int> > & factory_list =
reg.get<word, int>();
@@ -51,7 +51,7 @@
reg.clear();
// Now we can repeat the above - with the same results.
{
- reg.open("../bin/libRegistryLibrary.extension");
+ reg.open("libRegistryLibrary.extension");
std::list<counted_factory<word, int> > & factory_list =
reg.get<word, int>();
if (factory_list.size() != 1)
Modified: sandbox/libs/extension/test/hello_world_test.cpp
==============================================================================
--- sandbox/libs/extension/test/hello_world_test.cpp (original)
+++ sandbox/libs/extension/test/hello_world_test.cpp 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -24,7 +24,7 @@
BOOST_AUTO_TEST_CASE(hello_world_example)
{
// check if the library can be loaded
- shared_library l((std::string("../bin/libHelloWorldLib") + ".extension")
+ shared_library l((std::string("libHelloWorldLib") + ".extension")
.c_str());
BOOST_CHECK_EQUAL( l.open(), true );
Modified: sandbox/libs/extension/test/lib_caching_test.cpp
==============================================================================
--- sandbox/libs/extension/test/lib_caching_test.cpp (original)
+++ sandbox/libs/extension/test/lib_caching_test.cpp 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -23,22 +23,16 @@
#include "../examples/word.hpp"
-#define BOOST_EXTENSION_LIBS_DIRECTORY "../bin/"
-
using namespace boost::extensions;
/// tests if the SO caches libraries and if we can remove .extensions files before unloading
BOOST_AUTO_TEST_CASE(lib_caching_test)
{
- if(boost::filesystem::exists(BOOST_EXTENSION_LIBS_DIRECTORY
- "libHelloWorldCache.extension")) {
- boost::filesystem::remove(BOOST_EXTENSION_LIBS_DIRECTORY
- "libHelloWorldCache.extension");
+ if(boost::filesystem::exists("libHelloWorldCache.extension")) {
+ boost::filesystem::remove("libHelloWorldCache.extension");
}
- boost::filesystem::copy_file(BOOST_EXTENSION_LIBS_DIRECTORY
- "libHelloWorldLib.extension",
- BOOST_EXTENSION_LIBS_DIRECTORY
+ boost::filesystem::copy_file("libHelloWorldLib.extension",
"libHelloWorldCache.extension");
{
@@ -80,11 +74,8 @@
}
// replace the loaded library and try to reload
- boost::filesystem::remove(BOOST_EXTENSION_LIBS_DIRECTORY
- "libHelloWorldCache.extension");
- boost::filesystem::copy_file(BOOST_EXTENSION_LIBS_DIRECTORY
- "libHelloWorldLibv2.extension",
- BOOST_EXTENSION_LIBS_DIRECTORY
+ boost::filesystem::remove("libHelloWorldCache.extension");
+ boost::filesystem::copy_file("libHelloWorldLibv2.extension",
"libHelloWorldCache.extension");
{
@@ -160,8 +151,7 @@
++current_word;
- boost::filesystem::remove(BOOST_EXTENSION_LIBS_DIRECTORY
- "libHelloWorldCache.extension");
+ boost::filesystem::remove("libHelloWorldCache.extension");
std::auto_ptr<word> world_word_ptr(current_word->second.create());
BOOST_CHECK_EQUAL( !world_word_ptr.get(), 0 );
Modified: sandbox/libs/extension/test/registry_test.cpp
==============================================================================
--- sandbox/libs/extension/test/registry_test.cpp (original)
+++ sandbox/libs/extension/test/registry_test.cpp 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -23,16 +23,16 @@
{
registry reg;
BOOST_CHECK_EQUAL(reg.num_libraries(), size_t(0));
- BOOST_CHECK(reg.open("../bin/libRegistryLibrary.extension"));
+ BOOST_CHECK(reg.open("libRegistryLibrary.extension"));
BOOST_CHECK_EQUAL(reg.num_libraries(), size_t(1));
- BOOST_CHECK(reg.close("../bin/libRegistryLibrary.extension"));
+ BOOST_CHECK(reg.close("libRegistryLibrary.extension"));
BOOST_CHECK_EQUAL(reg.num_libraries(), size_t(0));
}
BOOST_AUTO_TEST_CASE(library_closing)
{ // this tests the requirements of the registry example
registry reg;
- BOOST_ASSERT(reg.open("../bin/libRegistryLibrary.extension"));
+ BOOST_ASSERT(reg.open("libRegistryLibrary.extension"));
{
std::list<counted_factory<word, int> > & factory_list =
reg.get<word, int>();
@@ -44,7 +44,7 @@
}
}
BOOST_CHECK(reg.clear());
- BOOST_ASSERT(reg.open("../bin/libRegistryLibrary.extension"));
+ BOOST_ASSERT(reg.open("libRegistryLibrary.extension"));
{
std::list<counted_factory<word, int> > & factory_list =
reg.get<word, int>();
Modified: sandbox/libs/reflection/doc/reflection.qbk
==============================================================================
--- sandbox/libs/reflection/doc/reflection.qbk (original)
+++ sandbox/libs/reflection/doc/reflection.qbk 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -20,6 +20,6 @@
[include introduction.qbk]
[include extension.qbk]
[include tutorials.qbk]
-[/ [include performance_analysis.qbk] ]
-[/ [include appendices.qbk] ]
+[/ [include performance_analysis.qbk]
+[/ [include appendices.qbk]
Modified: sandbox/libs/reflection/doc/tutorials.qbk
==============================================================================
--- sandbox/libs/reflection/doc/tutorials.qbk (original)
+++ sandbox/libs/reflection/doc/tutorials.qbk 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -7,12 +7,12 @@
[section Tutorials]
[include tutorial1.qbk]
-[/
-[include tutorial2.qbk]
-[include tutorial3.qbk]
-[include tutorial4.qbk]
-[include tutorial5.qbk]
-]
+
+[/ [include tutorial2.qbk]
+[/ [include tutorial3.qbk]
+[/ [include tutorial4.qbk]
+[/ [include tutorial5.qbk]
+
[endsect]
\ No newline at end of file
Modified: sandbox/libs/reflection/examples/extension/extension.cpp
==============================================================================
--- sandbox/libs/reflection/examples/extension/extension.cpp (original)
+++ sandbox/libs/reflection/examples/extension/extension.cpp 2008-02-14 12:51:41 EST (Thu, 14 Feb 2008)
@@ -19,13 +19,6 @@
#include <boost/reflection/reflector.hpp>
#include <iostream>
-// Define directory locations for cross platform
-// directory traversal.
-#if defined(MSC_VER) || defined(WIN32)
-#define BOOST_EXTENSION_DIR_START "..\\bin\\"
-#else
-#define BOOST_EXTENSION_DIR_START "../bin/"
-#endif
int main(void)
{
@@ -39,16 +32,22 @@
// Load the shared library using Boost.Extension
boost::extensions::shared_library lib
- ((std::string(BOOST_EXTENSION_DIR_START) +
- "libcar_lib.extension").c_str());
+ ("libcar_lib.extension");
lib.open();
-
+ if (!lib.is_open())
+ return 2;
+ if (!lib.get<void, std::map<std::string,
+ reflection> &>("extension_export_car")) {
+ return 3;
+ }
// Call an exported function to populate
// reflection_map
lib.get<void, std::map<std::string,
reflection> &>
("extension_export_car")(reflection_map);
- if (reflection_map.size() != size_t(2)) {
+ if (reflection_map.size() != size_t(2) ||
+ reflection_map.find("suv") == reflection_map.end() ||
+ reflection_map.find("compact") == reflection_map.end()) {
std::cout << "Could not load reflections!";
return 1;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk