You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by bo...@apache.org on 2009/02/16 15:54:08 UTC

svn commit: r744929 - in /xerces/c/branches/xerces-3.0/src/xercesc: util/Mutexes.cpp util/Mutexes.hpp validators/schema/SchemaValidator.cpp validators/schema/SchemaValidator.hpp

Author: borisk
Date: Mon Feb 16 14:53:58 2009
New Revision: 744929

URL: http://svn.apache.org/viewvc?rev=744929&view=rev
Log:
Rework fixes for SchemaValidator and XMLMutex to keep the interfaces
binary compatible with 3.0.0.

Modified:
    xerces/c/branches/xerces-3.0/src/xercesc/util/Mutexes.cpp
    xerces/c/branches/xerces-3.0/src/xercesc/util/Mutexes.hpp
    xerces/c/branches/xerces-3.0/src/xercesc/validators/schema/SchemaValidator.cpp
    xerces/c/branches/xerces-3.0/src/xercesc/validators/schema/SchemaValidator.hpp

Modified: xerces/c/branches/xerces-3.0/src/xercesc/util/Mutexes.cpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-3.0/src/xercesc/util/Mutexes.cpp?rev=744929&r1=744928&r2=744929&view=diff
==============================================================================
--- xerces/c/branches/xerces-3.0/src/xercesc/util/Mutexes.cpp (original)
+++ xerces/c/branches/xerces-3.0/src/xercesc/util/Mutexes.cpp Mon Feb 16 14:53:58 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,25 +30,38 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
+struct MutexData: XMemory
+{
+  void*          fHandle;
+  MemoryManager* fManager;
+};
+
 // ---------------------------------------------------------------------------
 //  XMLMutex: Constructors and Destructor
 // ---------------------------------------------------------------------------
 XMLMutex::XMLMutex(MemoryManager* const manager) :
-
-    fHandle(0),
-    fManager(manager)
+    fData(0)
 {
+  fData = new (manager) MutexData;
+
+  if (fData)
+  {
+    ((MutexData*)fData)->fManager = manager;
     // Ask the per-platform driver to make us a mutex
-    fHandle = XMLPlatformUtils::makeMutex(manager);
+    ((MutexData*)fData)->fHandle = XMLPlatformUtils::makeMutex(manager);
+  }
 }
 
 
 XMLMutex::~XMLMutex()
 {
-    if (fHandle)
+    if (fData)
     {
-        XMLPlatformUtils::closeMutex(fHandle, fManager);
-        fHandle = 0;
+      if (((MutexData*)fData)->fHandle)
+        XMLPlatformUtils::closeMutex(((MutexData*)fData)->fHandle,
+                                     ((MutexData*)fData)->fManager);
+
+      delete ((MutexData*)fData);
     }
 }
 
@@ -58,12 +71,12 @@
 // ---------------------------------------------------------------------------
 void XMLMutex::lock()
 {
-    XMLPlatformUtils::lockMutex(fHandle);
+    XMLPlatformUtils::lockMutex(((MutexData*)fData)->fHandle);
 }
 
 void XMLMutex::unlock()
 {
-    XMLPlatformUtils::unlockMutex(fHandle);
+    XMLPlatformUtils::unlockMutex(((MutexData*)fData)->fHandle);
 }
 
 

Modified: xerces/c/branches/xerces-3.0/src/xercesc/util/Mutexes.hpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-3.0/src/xercesc/util/Mutexes.hpp?rev=744929&r1=744928&r2=744929&view=diff
==============================================================================
--- xerces/c/branches/xerces-3.0/src/xercesc/util/Mutexes.hpp (original)
+++ xerces/c/branches/xerces-3.0/src/xercesc/util/Mutexes.hpp Mon Feb 16 14:53:58 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -56,15 +56,10 @@
     // -----------------------------------------------------------------------
     //  Private data members
     //
-    //  fHandle
-    //      The raw mutex handle. Its just a void pointer so we do not
-    //      pass judgement on its value at all. We just pass it into the
-    //      platform utilities methods which knows what's really in it.
-    // fManager
-    //      The MemoryManager that this XMLMutex was initialized with.
+    //  fData
+    //      Internal data structure (3.0.1 only).
     // -----------------------------------------------------------------------
-    void*          fHandle;
-    MemoryManager* fManager;
+    void*          fData;
 
 
     // -----------------------------------------------------------------------

Modified: xerces/c/branches/xerces-3.0/src/xercesc/validators/schema/SchemaValidator.cpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-3.0/src/xercesc/validators/schema/SchemaValidator.cpp?rev=744929&r1=744928&r2=744929&view=diff
==============================================================================
--- xerces/c/branches/xerces-3.0/src/xercesc/validators/schema/SchemaValidator.cpp (original)
+++ xerces/c/branches/xerces-3.0/src/xercesc/validators/schema/SchemaValidator.cpp Mon Feb 16 14:53:58 2009
@@ -55,14 +55,13 @@
     , fCurrentDatatypeValidator(0)
     , fNotationBuf(0)
     , fDatatypeBuffer(1023, manager)
-    , fTrailing(false)
-    , fSeenNonWhiteSpace(false)
     , fSeenId(false)
     , fTypeStack(0)
     , fMostRecentAttrValidator(0)
     , fErrorOccurred(false)
     , fElemIsSpecified(false)
 {
+    fTrailingSeenNonWhiteSpace.flags = 0;
     fTypeStack = new (fMemoryManager) ValueStackOf<ComplexTypeInfo*>(8, fMemoryManager);
 }
 
@@ -308,8 +307,7 @@
     // must rely on scanner to clear fDatatypeBuffer
     // since it may need to query its contents after this method completes
     fNil = false;
-    fTrailing=false;
-    fSeenNonWhiteSpace = false;
+    fTrailingSeenNonWhiteSpace.flags = 0;
     fCurrentDatatypeValidator = 0;
 
     // Went ok, so return success
@@ -338,8 +336,7 @@
 
 void SchemaValidator::reset()
 {
-    fTrailing = false;
-    fSeenNonWhiteSpace = false;
+    fTrailingSeenNonWhiteSpace.flags = 0;
     fSeenId = false;
 	fTypeStack->removeAllElements();
     delete fXsiType;
@@ -525,8 +522,7 @@
     if(fErrorOccurred) {
         fMostRecentAttrValidator = DatatypeValidatorFactory::getBuiltInRegistry()->get(SchemaSymbols::fgDT_ANYSIMPLETYPE);
     }
-    fTrailing = false;
-    fSeenNonWhiteSpace = false;
+    fTrailingSeenNonWhiteSpace.flags = 0;
 }
 
 void SchemaValidator::validateElement(const   XMLElementDecl*  elemDef)
@@ -727,8 +723,7 @@
     }
 
     fDatatypeBuffer.reset();
-    fTrailing = false;
-    fSeenNonWhiteSpace = false;
+    fTrailingSeenNonWhiteSpace.flags = 0;
     fSeenId = false;
 }
 
@@ -989,7 +984,7 @@
             , InContent
         };
 
-        States curState = fTrailing ? InWhitespace : InContent;
+        States curState = (fTrailingSeenNonWhiteSpace.flags & 0x01) ? InWhitespace : InContent;
         while (*srcPtr)
         {
             nextCh = *srcPtr++;
@@ -1000,25 +995,25 @@
                     curState = InWhitespace;
                     continue;
                 }
-                fSeenNonWhiteSpace = true;
+                fTrailingSeenNonWhiteSpace.flags |= 0x02;
             }
             else if (curState == InWhitespace)
             {
                 if (fCurReader->isWhitespace(nextCh))
                     continue;
-                if (fSeenNonWhiteSpace)
+                if (fTrailingSeenNonWhiteSpace.flags & 0x02)
                     toFill.append(chSpace);
                 curState = InContent;
-                fSeenNonWhiteSpace = true;
+                fTrailingSeenNonWhiteSpace.flags |= 0x02;
             }
             // Add this char to the target buffer
             toFill.append(nextCh);
         }
 
         if (fCurReader->isWhitespace(*(srcPtr-1)))
-          fTrailing = true;
+          fTrailingSeenNonWhiteSpace.flags |= 0x01; // set
         else
-          fTrailing = false;
+          fTrailingSeenNonWhiteSpace.flags &= 0x02; // clear
     }
 }
 

Modified: xerces/c/branches/xerces-3.0/src/xercesc/validators/schema/SchemaValidator.hpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-3.0/src/xercesc/validators/schema/SchemaValidator.hpp?rev=744929&r1=744928&r2=744929&view=diff
==============================================================================
--- xerces/c/branches/xerces-3.0/src/xercesc/validators/schema/SchemaValidator.hpp (original)
+++ xerces/c/branches/xerces-3.0/src/xercesc/validators/schema/SchemaValidator.hpp Mon Feb 16 14:53:58 2009
@@ -295,8 +295,13 @@
     DatatypeValidator*              fCurrentDatatypeValidator;
     XMLBuffer*                      fNotationBuf;
     XMLBuffer                       fDatatypeBuffer;
-    bool                            fTrailing;
-    bool                            fSeenNonWhiteSpace;
+    // Only for 3.0.1.
+    //
+    union
+    {
+      bool old;
+      unsigned char flags; // fTrailing - big 0; fSeenNonWhiteSpace - bit 1
+    } fTrailingSeenNonWhiteSpace;
     bool                            fSeenId;
     XSDErrorReporter                fSchemaErrorReporter;
     ValueStackOf<ComplexTypeInfo*>* fTypeStack;



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