void ConfigType::ValidateItem(const ConfigItem::Ptr& item) { /* Don't validate abstract items. */ if (item->IsAbstract()) return; Dictionary::Ptr attrs; DebugInfo debugInfo; String type, name; { ObjectLock olock(item); attrs = item->GetProperties(); debugInfo = item->GetDebugInfo(); type = item->GetType(); name = item->GetName(); } std::vector<String> locations; locations.push_back("Object '" + name + "' (Type: '" + type + "') at " + debugInfo.Path + ":" + Convert::ToString(debugInfo.FirstLine)); std::vector<TypeRuleList::Ptr> ruleLists; AddParentRules(ruleLists, GetSelf()); ruleLists.push_back(m_RuleList); ValidateDictionary(attrs, ruleLists, locations); }
static inline Value NewObject(ScriptFrame& frame, bool abstract, const String& type, const String& name, const boost::shared_ptr<Expression>& filter, const String& zone, const String& package, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo()) { ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo); String checkName = name; if (!abstract) { Type::Ptr ptype = Type::GetByName(type); NameComposer *nc = dynamic_cast<NameComposer *>(ptype.get()); if (nc) checkName = nc->MakeName(name, Dictionary::Ptr()); } if (!checkName.IsEmpty()) { ConfigItem::Ptr oldItem = ConfigItem::GetObject(type, checkName); if (oldItem) { std::ostringstream msgbuf; msgbuf << "Object '" << name << "' of type '" << type << "' re-defined: " << debugInfo << "; previous definition: " << oldItem->GetDebugInfo(); BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), debugInfo)); } } item->SetType(type); item->SetName(name); item->AddExpression(new OwnedExpression(expression)); item->SetAbstract(abstract); item->SetScope(EvaluateClosedVars(frame, closedVars)); item->SetZone(zone); item->SetPackage(package); item->SetFilter(filter); item->Compile()->Register(); return Empty; }