diff --git a/include/boost/python/detail/config.hpp b/include/boost/python/detail/config.hpp index ff22e78e..0fc1093a 100644 --- a/include/boost/python/detail/config.hpp +++ b/include/boost/python/detail/config.hpp @@ -65,4 +65,68 @@ # endif # endif +/***************************************************************************** + * + * Set up dll import/export options: + * + ****************************************************************************/ + +// backwards compatibility: +#ifdef BOOST_RE_STATIC_LIB +# define BOOST_PYTHON_STATIC_LINK +#endif + +#if defined(BOOST_MSVC) && defined(_DLL) +# define BOOST_PYTHON_HAS_DLL_RUNTIME +#endif + +#if defined(__BORLANDC__) && defined(_RTLDLL) +# define BOOST_PYTHON_HAS_DLL_RUNTIME +#endif + +#if defined(__ICL) && defined(_DLL) +# define BOOST_PYTHON_HAS_DLL_RUNTIME +#endif + +#if defined(BOOST_PYTHON_HAS_DLL_RUNTIME) && !defined(BOOST_PYTHON_STATIC_LINK) +# if defined(BOOST_PYTHON_SOURCE) +# define BOOST_PYTHON_DECL __declspec(dllexport) +# define BOOST_PYTHON_BUILD_DLL +# else +# define BOOST_PYTHON_DECL __declspec(dllimport) +# endif +#endif + +#ifndef BOOST_PYTHON_DECL +# define BOOST_PYTHON_DECL +#endif + +#if (defined(BOOST_MSVC) || defined(__BORLANDC__)) && !defined(BOOST_PYTHON_NO_LIB) && !defined(BOOST_PYTHON_SOURCE) +# include +#endif + +// Borland C++ Fix/error check: +#if defined(__BORLANDC__) +# if (__BORLANDC__ == 0x550) || (__BORLANDC__ == 0x551) + // problems with std::basic_string and dll RTL: +# if defined(_RTLDLL) && defined(_RWSTD_COMPILE_INSTANTIATE) +# ifdef BOOST_PYTHON_BUILD_DLL +# error _RWSTD_COMPILE_INSTANTIATE must not be defined when building regex++ as a DLL +# else +# pragma warn defining _RWSTD_COMPILE_INSTANTIATE when linking to the DLL version of the RTL may produce memory corruption problems in std::basic_string, as a result of separate versions of basic_string's static data in the RTL and you're exe/dll: be warned!! +# endif +# endif +# ifndef _RTLDLL + // this is harmless for a staic link: +# define _RWSTD_COMPILE_INSTANTIATE +# endif +# endif + // + // VCL support: + // if we're building a console app then there can't be any VCL (can there?) +# if !defined(__CONSOLE__) && !defined(_NO_VCL) +# define BOOST_PYTHON_USE_VCL +# endif +#endif + #endif // CONFIG_DWA052200_H_ diff --git a/include/boost/python/detail/extension_class.hpp b/include/boost/python/detail/extension_class.hpp index f7be9afb..00f9b6b4 100644 --- a/include/boost/python/detail/extension_class.hpp +++ b/include/boost/python/detail/extension_class.hpp @@ -52,12 +52,12 @@ template struct operand_select; template struct choose_unary_op; template struct define_operator; -meta_class* extension_meta_class(); -extension_instance* get_extension_instance(PyObject* p); -void report_missing_instance_data(extension_instance*, class_t*, const std::type_info&); -void report_missing_ptr_data(extension_instance*, class_t*, const std::type_info&); -void report_missing_class_object(const std::type_info&); -void report_released_smart_pointer(const std::type_info&); +BOOST_PYTHON_DECL meta_class* extension_meta_class(); +BOOST_PYTHON_DECL extension_instance* get_extension_instance(PyObject* p); +BOOST_PYTHON_DECL void report_missing_instance_data(extension_instance*, class_t*, const std::type_info&); +BOOST_PYTHON_DECL void report_missing_ptr_data(extension_instance*, class_t*, const std::type_info&); +BOOST_PYTHON_DECL void report_missing_class_object(const std::type_info&); +BOOST_PYTHON_DECL void report_released_smart_pointer(const std::type_info&); template T* check_non_null(T* p) @@ -71,7 +71,7 @@ template class held_instance; typedef void* (*conversion_function_ptr)(void*); -struct base_class_info +struct BOOST_PYTHON_DECL base_class_info { base_class_info(extension_class_base* t, conversion_function_ptr f) :class_object(t), convert(f) @@ -85,7 +85,7 @@ typedef base_class_info derived_class_info; struct add_operator_base; -class extension_class_base : public class_t +class BOOST_PYTHON_DECL extension_class_base : public class_t { public: extension_class_base(const char* name); @@ -378,7 +378,7 @@ namespace detail { template class instance_holder; -class read_only_setattr_function : public function +class BOOST_PYTHON_DECL read_only_setattr_function : public function { public: read_only_setattr_function(const char* name); @@ -725,7 +725,7 @@ public: // Abstract base class for all obj holders. Base for template class // instance_holder<>, below. -class instance_holder_base +class BOOST_PYTHON_DECL instance_holder_base { public: virtual ~instance_holder_base() {} @@ -813,7 +813,7 @@ class instance_ptr_holder : public instance_holder PtrType m_ptr; }; -class extension_instance : public instance +class BOOST_PYTHON_DECL extension_instance : public instance { public: extension_instance(PyTypeObject* class_); diff --git a/include/boost/python/detail/functions.hpp b/include/boost/python/detail/functions.hpp index eff05d65..486d73f9 100644 --- a/include/boost/python/detail/functions.hpp +++ b/include/boost/python/detail/functions.hpp @@ -29,7 +29,7 @@ class extension_instance; // function -- // the common base class for all overloadable function and method objects // supplied by the library. -class function : public python_object +class BOOST_PYTHON_DECL function : public python_object { public: function(); @@ -201,7 +201,7 @@ inline function* new_virtual_function( // the expression a.b where a is an instance or extension_instance object and b // is a callable object not found in the obj namespace but on its class or // a base class. -class bound_function : public python_object +class BOOST_PYTHON_DECL bound_function : public python_object { public: static bound_function* create(const ref& target, const ref& fn); diff --git a/include/boost/python/detail/init_function.hpp b/include/boost/python/detail/init_function.hpp index c0c50272..69df703d 100644 --- a/include/boost/python/detail/init_function.hpp +++ b/include/boost/python/detail/init_function.hpp @@ -230,7 +230,7 @@ struct init_function } }; -class init : public function +class BOOST_PYTHON_DECL init : public function { private: // override function hook PyObject* do_call(PyObject* args, PyObject* keywords) const; diff --git a/include/boost/python/detail/signatures.hpp b/include/boost/python/detail/signatures.hpp index 2be75b52..e216f688 100644 --- a/include/boost/python/detail/signatures.hpp +++ b/include/boost/python/detail/signatures.hpp @@ -17,7 +17,7 @@ namespace boost { namespace python { namespace detail { // A stand-in for the built-in void. This one can be passed to functions and // (under MSVC, which has a bug, be used as a default template type parameter). -struct void_t {}; +struct BOOST_PYTHON_DECL void_t {}; } // An envelope in which type information can be delivered for the purposes diff --git a/include/boost/python/detail/singleton.hpp b/include/boost/python/detail/singleton.hpp index 07d794ac..3e7d91af 100644 --- a/include/boost/python/detail/singleton.hpp +++ b/include/boost/python/detail/singleton.hpp @@ -13,7 +13,7 @@ namespace boost { namespace python { namespace detail { -struct empty {}; +struct BOOST_PYTHON_DECL empty {}; template struct singleton : Base { diff --git a/include/boost/python/detail/types.hpp b/include/boost/python/detail/types.hpp index 954e0213..f4e62f88 100644 --- a/include/boost/python/detail/types.hpp +++ b/include/boost/python/detail/types.hpp @@ -37,7 +37,7 @@ namespace detail { class instance_holder_base; -class type_object_base : public python_type +class BOOST_PYTHON_DECL type_object_base : public python_type { public: explicit type_object_base(PyTypeObject* type_type); @@ -327,7 +327,7 @@ PyObject* reprable::instance_repr(PyObject* obj) const // memory. Reference counting is used to free unused memory. // This is useful because method tables of related extension classes tend // to be identical, so less memory is needed for them. - class shared_pod_manager + class BOOST_PYTHON_DECL shared_pod_manager { typedef std::pair holder; typedef std::vector storage; @@ -394,7 +394,7 @@ PyObject* reprable::instance_repr(PyObject* obj) const }; - void add_capability(type_object_base::capability capability, + BOOST_PYTHON_DECL void add_capability(type_object_base::capability capability, PyTypeObject* dest); // This macro gets the length of an array as a compile-time constant, and will diff --git a/include/boost/python/detail/void_adaptor.hpp b/include/boost/python/detail/void_adaptor.hpp index c2ecc2b0..3d60e4bf 100644 --- a/include/boost/python/detail/void_adaptor.hpp +++ b/include/boost/python/detail/void_adaptor.hpp @@ -8,7 +8,7 @@ namespace boost { namespace python { namespace detail { - extern PyObject arbitrary_object; + BOOST_PYTHON_DECL extern PyObject arbitrary_object; template struct void_adaptor