You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2003/08/16 20:42:50 UTC

cvs commit: xml-xerces/c/src/xercesc/validators/datatype UnionDatatypeValidator.cpp UnionDatatypeValidator.hpp

neilg       2003/08/16 11:42:49

  Modified:    c/src/xercesc/validators/datatype UnionDatatypeValidator.cpp
                        UnionDatatypeValidator.hpp
  Log:
  fix for bug 22457.  Union types that are restrictions of other union types were previously considered not to inherit their parents member types.  This is at variance with the behaviour of the Java parser and apparently with the spec, so I have changed this.
  
  Revision  Changes    Path
  1.11      +12 -3     xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp
  
  Index: UnionDatatypeValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- UnionDatatypeValidator.cpp	16 May 2003 06:01:57 -0000	1.10
  +++ UnionDatatypeValidator.cpp	16 Aug 2003 18:42:49 -0000	1.11
  @@ -57,6 +57,9 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.11  2003/08/16 18:42:49  neilg
  + * fix for bug 22457.  Union types that are restrictions of other union types were previously considered not to inherit their parents member types.  This is at variance with the behaviour of the Java parser and apparently with the spec, so I have changed this.
  + *
    * Revision 1.10  2003/05/16 06:01:57  knoaman
    * Partial implementation of the configurable memory manager.
    *
  @@ -127,6 +130,7 @@
   ,fEnumeration(0)
   ,fMemberTypeValidators(0)
   ,fValidatedDatatype(0)
  +,fMemberTypesInherited(false)
   {}
   
   UnionDatatypeValidator::~UnionDatatypeValidator()
  @@ -143,6 +147,7 @@
   ,fEnumeration(0)
   ,fMemberTypeValidators(0)
   ,fValidatedDatatype(0)
  +,fMemberTypesInherited(false)
   {
       if ( !memberTypeValidators )
       {
  @@ -159,12 +164,16 @@
                           , RefHashTableOf<KVStringPair>* const facets
                           , RefArrayVectorOf<XMLCh>*      const enums
                           , const int                           finalSet
  -                        , MemoryManager* const                manager)
  +                        , MemoryManager* const                manager
  +                        , RefVectorOf<DatatypeValidator>* const memberTypeValidators 
  +                        , const bool memberTypesInherited
  +                        )
   :DatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::Union, manager)
   ,fEnumerationInherited(false)
   ,fEnumeration(0)
  -,fMemberTypeValidators(0)
  +,fMemberTypeValidators(memberTypeValidators)
   ,fValidatedDatatype(0)
  +,fMemberTypesInherited(memberTypesInherited)
   {
       //
       // baseValidator another UnionDTV from which,
  
  
  
  1.10      +16 -16    xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp
  
  Index: UnionDatatypeValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/datatype/UnionDatatypeValidator.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- UnionDatatypeValidator.hpp	15 May 2003 18:53:27 -0000	1.9
  +++ UnionDatatypeValidator.hpp	16 Aug 2003 18:42:49 -0000	1.10
  @@ -57,6 +57,9 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.10  2003/08/16 18:42:49  neilg
  + * fix for bug 22457.  Union types that are restrictions of other union types were previously considered not to inherit their parents member types.  This is at variance with the behaviour of the Java parser and apparently with the spec, so I have changed this.
  + *
    * Revision 1.9  2003/05/15 18:53:27  knoaman
    * Partial implementation of the configurable memory manager.
    *
  @@ -151,7 +154,7 @@
       // <simpleType name="derivedUnion">
       //      <restriction base="nativeUnion">
       //          <pattern     value="patter_value"/>
  -    //          <enumeartion value="enum_value"/>
  +    //          <enumeration value="enum_value"/>
       //      </restriction>
       // </simpleType>
       //
  @@ -162,6 +165,8 @@
           , RefArrayVectorOf<XMLCh>* const enums
           , const int finalSet
           , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
  +        , RefVectorOf<DatatypeValidator>* const memberTypeValidators = 0
  +        , const bool memberTypesInherited = true
       );
   
       virtual ~UnionDatatypeValidator();
  @@ -292,10 +297,10 @@
       //  Private data members
       //
       //  fEnumeration
  -    //      we own it.
  +    //      we own it (or not, depending on state of fEnumerationInherited).
       //
       //  fMemberTypeValidators
  -    //      we own it.
  +    //      we own it (or not, depending on the state of fMemberTypesInherited).
       //
       //  fValidatedDatatype
       //      the dataTypeValidator  that was actually used to validate the last time validate was called
  @@ -303,6 +308,7 @@
       // -----------------------------------------------------------------------
   
        bool                 fEnumerationInherited;
  +     bool                 fMemberTypesInherited;
        RefArrayVectorOf<XMLCh>*  fEnumeration;
        RefVectorOf<DatatypeValidator>*  fMemberTypeValidators;
        DatatypeValidator*               fValidatedDatatype;
  @@ -316,7 +322,7 @@
       , MemoryManager* const                manager
   )
   {
  -    return (DatatypeValidator*) new (manager) UnionDatatypeValidator(this, facets, enums, finalSet, manager);
  +    return (DatatypeValidator*) new (manager) UnionDatatypeValidator(this, facets, enums, finalSet, manager, fMemberTypeValidators, true);
   }
   
   inline void UnionDatatypeValidator::validate( const XMLCh* const content)
  @@ -330,7 +336,7 @@
       if ( !fEnumerationInherited && fEnumeration)
           delete fEnumeration;
   
  -    if (fMemberTypeValidators)
  +    if (!fMemberTypesInherited && fMemberTypeValidators)
           delete fMemberTypeValidators;
       
   }
  @@ -360,27 +366,21 @@
   inline
   RefVectorOf<DatatypeValidator>* UnionDatatypeValidator::getMemberTypeValidators() const
   {
  -    UnionDatatypeValidator* thisdv = (UnionDatatypeValidator*)this; // cast away constness
  -
  -    while (thisdv->getBaseValidator())
  -        thisdv = (UnionDatatypeValidator*) thisdv->getBaseValidator();
  -
  -    return thisdv->fMemberTypeValidators;
  +    return this->fMemberTypeValidators;
   }
   
   inline bool UnionDatatypeValidator::isAtomic() const {
   
   
  -    RefVectorOf<DatatypeValidator>* memberDVs = getMemberTypeValidators();
   
  -    if (!memberDVs) {
  +    if (!fMemberTypeValidators) {
           return false;
       }
   
  -    unsigned int memberSize = memberDVs->size();
  +    unsigned int memberSize = fMemberTypeValidators->size();
   
       for (unsigned int i=0; i < memberSize; i++) {
  -        if (!memberDVs->elementAt(i)->isAtomic()) {
  +        if (!fMemberTypeValidators->elementAt(i)->isAtomic()) {
               return false;
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org