summaryrefslogtreecommitdiff
path: root/cpp/src/FreezeScript/Data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/FreezeScript/Data.cpp')
-rw-r--r--cpp/src/FreezeScript/Data.cpp64
1 files changed, 38 insertions, 26 deletions
diff --git a/cpp/src/FreezeScript/Data.cpp b/cpp/src/FreezeScript/Data.cpp
index ff535ed14c2..9f97ec4a56a 100644
--- a/cpp/src/FreezeScript/Data.cpp
+++ b/cpp/src/FreezeScript/Data.cpp
@@ -2487,37 +2487,35 @@ FreezeScript::ObjectRef::setValue(const ObjectDataPtr& value)
//
// ObjectFactory
//
-FreezeScript::ObjectFactory::ObjectFactory(const DataFactoryPtr& factory, const Slice::UnitPtr& unit) :
- _factory(factory), _unit(unit)
-{
-}
-
Ice::ObjectPtr
FreezeScript::ObjectFactory::create(const string& id)
{
Ice::ObjectPtr result;
- if(id == Ice::Object::ice_staticId())
- {
- result = new ObjectReader(_factory, _unit->builtin(Slice::Builtin::KindObject));
- }
- else
- {
- Slice::TypeList l = _unit->lookupTypeNoBuiltin(id);
- if(!l.empty())
- {
- Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(l.front());
- if(!decl)
- {
- _factory->getErrorReporter()->error("Slice definition for `" + id + "' is not a class");
- }
- Slice::ClassDefPtr def = decl->definition();
- if(!def)
- {
- _factory->getErrorReporter()->error("no class definition for `" + id + "'");
- }
- result = new ObjectReader(_factory, decl);
- }
+ if(_factory)
+ {
+ if(id == Ice::Object::ice_staticId())
+ {
+ result = new ObjectReader(_factory, _unit->builtin(Slice::Builtin::KindObject));
+ }
+ else
+ {
+ Slice::TypeList l = _unit->lookupTypeNoBuiltin(id);
+ if(!l.empty())
+ {
+ Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(l.front());
+ if(!decl)
+ {
+ _factory->getErrorReporter()->error("Slice definition for `" + id + "' is not a class");
+ }
+ Slice::ClassDefPtr def = decl->definition();
+ if(!def)
+ {
+ _factory->getErrorReporter()->error("no class definition for `" + id + "'");
+ }
+ result = new ObjectReader(_factory, decl);
+ }
+ }
}
return result;
@@ -2528,6 +2526,20 @@ FreezeScript::ObjectFactory::destroy()
{
}
+void
+FreezeScript::ObjectFactory::activate(const DataFactoryPtr& factory, const Slice::UnitPtr& unit)
+{
+ assert(!_factory && !_unit);
+ _factory = factory;
+ _unit = unit;
+}
+void
+FreezeScript::ObjectFactory::deactivate()
+{
+ _factory = 0;
+ _unit = 0;
+}
+
//
// DataVisitor
//