Add object dependency tracking to make sure that during nested function calls all returned values are not prematurely destructed.

All tests pass on vc2008 now.
This commit is contained in:
Jason Turner
2010-10-02 13:26:06 +00:00
parent 43dbd8ac78
commit 74e719c053
5 changed files with 106 additions and 58 deletions

View File

@@ -70,10 +70,15 @@ namespace chaiscript
return *this;
}
~Data()
{
}
Type_Info m_type_info;
boost::any m_obj;
bool m_is_ref;
boost::function<bool (boost::any*)> m_is_null;
std::vector<boost::shared_ptr<Data> > m_dependencies;
};
struct Object_Data
@@ -245,6 +250,24 @@ namespace chaiscript
return !is_ref();
}
void clear_dependencies()
{
m_data->m_dependencies.clear();
}
template<typename InItr>
void add_dependencies(InItr begin, const InItr &end)
{
while (begin != end)
{
if (begin->m_data != m_data)
{
m_data->m_dependencies.push_back(begin->m_data);
}
++begin;
}
}
private:
boost::shared_ptr<Data> m_data;