#include <map>
+template<class T>
+inline T* get_pointer(boost::weak_ptr<T> const& p)
+{
+ return p.lock().get();
+}
+
/**
* Bindings between C++ and the Nasal scripting language
*/
++parent )
{
pointer ptr = fromNasal(c, *parent);
- if( ptr.get() )
+ if( get_pointer(ptr) )
return ptr;
}
}
*/
static pointer* createInstance(const pointer& ptr)
{
- return ptr.get() ? new pointer(ptr) : 0;
+ return get_pointer(ptr) ? new pointer(ptr) : 0;
}
static pointer getPtr(void* ptr)
static raw_type* getRawPtr(void* ptr)
{
if( ptr )
- return static_cast<pointer*>(ptr)->get();
+ return get_pointer(*static_cast<pointer*>(ptr));
else
return 0;
}
static raw_type* getRawPtr(const pointer& ptr)
{
- return ptr.get();
+ return get_pointer(ptr);
}
void addDerived( const internal::GhostMetadata* derived_meta,
#include "NasalString.hxx"
#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
#include <cstring>
#include <iostream>
typedef boost::shared_ptr<DoubleDerived> DoubleDerivedPtr;
typedef boost::shared_ptr<DoubleDerived2> DoubleDerived2Ptr;
+typedef boost::weak_ptr<Derived> DerivedWeakPtr;
+
naRef derivedFreeMember(Derived&, const nasal::CallContext&) { return naNil(); }
naRef f_derivedGetX(naContext c, const Derived& d)
{
.member("base", &DoubleDerived2::getBase)
.method("doIt", &DoubleDerived2::doSomeBaseWork);
+ Ghost<DerivedWeakPtr>::init("DerivedWeakPtr");
+
VERIFY( Ghost<BasePtr>::isInit() );
nasal::to_nasal(c, DoubleDerived2Ptr());