Пример #1
0
  void testXdr()
  {
    ontologydto::TypeDTO* typeDTO = new ontologydto::TypeDTO(*_typeElement);
    ontology::Type type(*typeDTO);

    ontologydto::TypeDTO* otherTypeDTO = new ontologydto::TypeDTO(*_typeElement);
    ontology::Type otherType(*otherTypeDTO);

    Instance instance(type);

    std::string name("Instance name.");
    std::string otherName("other Instance name.");
    instance.setName(name);

    iostream::XdrOutputStream ostream("testfile");
    instance.encode(ostream);
    ostream.close();

    std::map <int, void*> addressMappings;
    addressMappings[(int) &type] = static_cast <void*> (&type);
    addressMappings[(int) &otherType] = static_cast <void*> (&otherType);

    iostream::XdrInputStream istream("testfile");
    Instance decodedInst(istream, addressMappings);
    istream.close();

    remove("testfile");

    assertTrue(decodedInst.getName() == name);
    assertFalse(decodedInst.getName() == otherName);
    assertTrue(&(decodedInst.getType()) == &type);
    assertFalse(&(decodedInst.getType()) == &otherType);
  }
Пример #2
0
  void createItem(AbstractTypeData* item) const {
    TypeSystem::self().copy(*m_item.d_ptr, *item, true);
    Q_ASSERT(!item->m_dynamic);
#ifdef DEBUG_TYPE_REPOSITORY
    AbstractType::Ptr otherType( TypeSystem::self().create(const_cast<AbstractTypeData*>(item)) );
    if(!otherType->equals(&m_item)) {
      //For debugging, so one can trace what happened
      qCWarning(LANGUAGE) << "created type in repository does not equal source type:" << m_item.toString() << otherType->toString();
      TypeSystem::self().copy(*m_item.d_ptr, *item, true);
      otherType->equals(&m_item);
    }
#ifdef ASSERT_ON_PROBLEM
    Q_ASSERT(otherType->equals(&m_item));
#endif
#endif
    item->inRepository = true;
  }
Пример #3
0
TypeInfo TypeInfo::resolveType(TypeInfo const &__type, CodeModelItem __scope) {
    CodeModel *__model = __scope->model();
    Q_ASSERT(__model != 0);

    CodeModelItem __item = __model->findItem(__type.qualifiedName(), __scope);

    // Copy the type and replace with the proper qualified name. This
    // only makes sence to do if we're actually getting a resolved
    // type with a namespace. We only get this if the returned type
    // has more than 2 entries in the qualified name... This test
    // could be improved by returning if the type was found or not.
    TypeInfo otherType(__type);
    if (__item && __item->qualifiedName().size() > 1) {
        otherType.setQualifiedName(__item->qualifiedName());
    }

    if (TypeAliasModelItem __alias = model_dynamic_cast<TypeAliasModelItem> (__item))
        return resolveType(TypeInfo::combine(__alias->type(), otherType), __scope);

    return otherType;
}
Пример #4
0
 bool equals(const AbstractTypeData* item) const {
   AbstractType::Ptr otherType( TypeSystem::self().create(const_cast<AbstractTypeData*>(item)) );
   if(!otherType)
     return false;
   return m_item.equals(otherType.data());
 }