cppbind::Ghost: improve compiler error message for wrong usage.
This commit is contained in:
parent
4931ce0364
commit
e5acc3f048
@ -201,6 +201,20 @@ namespace nasal
|
|||||||
typedef SGSharedPtr<internal::MethodHolder> MethodHolderPtr;
|
typedef SGSharedPtr<internal::MethodHolder> MethodHolderPtr;
|
||||||
typedef SGWeakPtr<internal::MethodHolder> MethodHolderWeakPtr;
|
typedef SGWeakPtr<internal::MethodHolder> MethodHolderWeakPtr;
|
||||||
|
|
||||||
|
// Dummy template to create shorter and easy to understand compile errors if
|
||||||
|
// trying to wrap the wrong type as a Ghost.
|
||||||
|
template<class T, class Enable = void>
|
||||||
|
class Ghost
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BOOST_STATIC_ASSERT(("Ghost can only wrap shared pointer!"
|
||||||
|
&& is_strong_ref<T>::value
|
||||||
|
));
|
||||||
|
|
||||||
|
static Ghost& init(const std::string& name);
|
||||||
|
static bool isInit();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for exposing C++ objects to Nasal
|
* Class for exposing C++ objects to Nasal
|
||||||
*
|
*
|
||||||
@ -241,11 +255,11 @@ namespace nasal
|
|||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
template<class T>
|
template<class T>
|
||||||
class Ghost:
|
class Ghost<T, typename boost::enable_if<is_strong_ref<T> >::type>:
|
||||||
public internal::GhostMetadata
|
public internal::GhostMetadata
|
||||||
{
|
{
|
||||||
// Shared pointer required for Ghost (no weak pointer!)
|
// Shared pointer required for Ghost (no weak pointer!)
|
||||||
BOOST_STATIC_ASSERT((shared_ptr_traits<T>::is_strong::value));
|
BOOST_STATIC_ASSERT((is_strong_ref<T>::value));
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename T::element_type raw_type;
|
typedef typename T::element_type raw_type;
|
||||||
@ -871,7 +885,7 @@ namespace nasal
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
template<class>
|
template<class, class>
|
||||||
friend class Ghost;
|
friend class Ghost;
|
||||||
|
|
||||||
static naGhostType _ghost_type_strong, //!< Stored as shared pointer
|
static naGhostType _ghost_type_strong, //!< Stored as shared pointer
|
||||||
@ -1283,9 +1297,14 @@ namespace nasal
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
naGhostType Ghost<T>::_ghost_type_strong;
|
naGhostType
|
||||||
|
Ghost<T, typename boost::enable_if<is_strong_ref<T> >::type>
|
||||||
|
::_ghost_type_strong;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
naGhostType Ghost<T>::_ghost_type_weak;
|
naGhostType
|
||||||
|
Ghost<T, typename boost::enable_if<is_strong_ref<T> >::type>
|
||||||
|
::_ghost_type_weak;
|
||||||
|
|
||||||
} // namespace nasal
|
} // namespace nasal
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user