dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnet/image class.c,1.19,1.20 context.c,1.8,1


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnet/image class.c,1.19,1.20 context.c,1.8,1.9 image.h,1.21,1.22
Date: Sat, 22 Feb 2003 21:28:21 -0500

Update of /cvsroot/dotgnu-pnet/pnet/image
In directory subversions:/tmp/cvs-serv26546/image

Modified Files:
        class.c context.c image.h 
Log Message:


Detect nested namespaces that aren't defined in the program but do
exist in the system library (Bug #2426).


Index: class.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/class.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** class.c     15 Feb 2003 01:57:52 -0000      1.19
--- class.c     23 Feb 2003 02:28:19 -0000      1.20
***************
*** 177,180 ****
--- 177,192 ----
        }
  
+       /* Add the namespace to the context's namespace table if not present */
+       if(namespace)
+       {
+               if(ILHashFind(image->context->namespaceHash, namespace) == 0)
+               {
+                       if(!ILHashAdd(image->context->namespaceHash, info))
+                       {
+                               return 0;
+                       }
+               }
+       }
+ 
        /* Done */
        return info;
***************
*** 1694,1697 ****
--- 1706,1722 ----
        member->nextMember = 0;
        info->lastMember = member;
+ }
+ 
+ int ILClassNamespaceIsValid(ILContext *context, const char *nspace)
+ {
+       if(nspace)
+       {
+               return (ILHashFind(context->namespaceHash, nspace) != 0);
+       }
+       else
+       {
+               /* The empty namespace name is always valid */
+               return 1;
+       }
  }
  

Index: context.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/context.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** context.c   25 Nov 2002 03:05:55 -0000      1.8
--- context.c   23 Feb 2003 02:28:19 -0000      1.9
***************
*** 139,142 ****
--- 139,199 ----
  }
  
+ /*
+  * Compute the hash value for a namespace.
+  */
+ static unsigned long NamespaceHash_Compute(const ILClass *classInfo)
+ {
+       if(classInfo->namespace)
+       {
+               return HashIgnoreCase(0, classInfo->namespace,
+                                                         
strlen(classInfo->namespace));
+       }
+       else
+       {
+               return 0;
+       }
+ }
+ 
+ /*
+  * Compute the hash value for a namespace key.
+  */
+ static unsigned long NamespaceHash_KeyCompute(const char *key)
+ {
+       if(key)
+       {
+               return HashIgnoreCase(0, key, strlen(key));
+       }
+       else
+       {
+               return 0;
+       }
+ }
+ 
+ /*
+  * Match a hash table element against a supplied namespace key.
+  */
+ static int NamespaceHash_Match(const ILClass *classInfo, const char *key)
+ {
+       int len;
+       if(classInfo->namespace)
+       {
+               if(!key)
+               {
+                       return 0;
+               }
+               len = strlen(key);
+               if(strncmp(classInfo->namespace, key, len) != 0 ||
+                  classInfo->namespace[len] != '\0')
+               {
+                       return 0;
+               }
+               return 1;
+       }
+       else
+       {
+               return (key == 0);
+       }
+ }
+ 
  /* Defined in "synthetic.c" */
  int _ILContextSyntheticInit(ILContext *context);
***************
*** 145,162 ****
  {
        ILContext *context = (ILContext *)ILCalloc(1, sizeof(ILContext));
!       if(context)
        {
!               if((context->classHash = ILHashCreate
!                                       (IL_CONTEXT_HASH_SIZE,
!                                    (ILHashComputeFunc)ClassHash_Compute,
!                                        
(ILHashKeyComputeFunc)ClassHash_KeyCompute,
!                                        (ILHashMatchFunc)ClassHash_Match,
!                                        (ILHashFreeFunc)0)) == 0)
!               {
!                       ILFree(context);
!                       return 0;
!               }
!               ILMemPoolInitType(&(context->typePool), ILType, 0);
        }
        if(!_ILContextSyntheticInit(context))
        {
--- 202,220 ----
  {
        ILContext *context = (ILContext *)ILCalloc(1, sizeof(ILContext));
!       if(!context)
        {
!               return 0;
!       }
!       if((context->classHash = ILHashCreate
!                               (IL_CONTEXT_HASH_SIZE,
!                            (ILHashComputeFunc)ClassHash_Compute,
!                                (ILHashKeyComputeFunc)ClassHash_KeyCompute,
!                                (ILHashMatchFunc)ClassHash_Match,
!                                (ILHashFreeFunc)0)) == 0)
!       {
!               ILFree(context);
!               return 0;
        }
+       ILMemPoolInitType(&(context->typePool), ILType, 0);
        if(!_ILContextSyntheticInit(context))
        {
***************
*** 164,167 ****
--- 222,235 ----
                return 0;
        }
+       if((context->namespaceHash = ILHashCreate
+                               (IL_CONTEXT_NS_HASH_SIZE,
+                            (ILHashComputeFunc)NamespaceHash_Compute,
+                                (ILHashKeyComputeFunc)NamespaceHash_KeyCompute,
+                                (ILHashMatchFunc)NamespaceHash_Match,
+                                (ILHashFreeFunc)0)) == 0)
+       {
+               ILFree(context);
+               return 0;
+       }
        return context;
  }
***************
*** 177,180 ****
--- 245,251 ----
        /* Destroy the class hash */
        ILHashDestroy(context->classHash);
+ 
+       /* Destroy the namespace hash */
+       ILHashDestroy(context->namespaceHash);
  
        /* Destroy the synthetic types hash */

Index: image.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/image/image.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** image.h     20 Feb 2003 22:35:21 -0000      1.21
--- image.h     23 Feb 2003 02:28:19 -0000      1.22
***************
*** 59,62 ****
--- 59,63 ----
   */
  #define       IL_CONTEXT_HASH_SIZE    512
+ #define       IL_CONTEXT_NS_HASH_SIZE 64
  struct _tagILContext
  {
***************
*** 80,83 ****
--- 81,87 ----
        char              **libraryDirs;
        int                             numLibraryDirs;
+ 
+       /* Hash table to keeps track of valid namespaces */
+       ILHashTable        *namespaceHash;
  
  };





reply via email to

[Prev in Thread] Current Thread [Next in Thread]