Changeset 45

Show
Ignore:
Timestamp:
07/02/04 15:10:33 (4 years ago)
Author:
DenisG
Message:

[AprSharp] Introduce ReferenceEquals? in IAprUnmanaged and CastMake? for AprArray?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/AprSharp/dev/src/AprAllocator.cs

    r43 r45  
    5050        } 
    5151 
     52        public bool ReferenceEquals(IAprUnmanaged obj) 
     53        { 
     54            return(obj.ToIntPtr() == ToIntPtr()); 
     55        } 
     56         
    5257        public static implicit operator IntPtr(AprAllocator allocator) 
    5358        { 
  • trunk/AprSharp/dev/src/AprArray.cs

    r43 r45  
    8686        } 
    8787 
     88        public bool ReferenceEquals(IAprUnmanaged obj) 
     89        { 
     90            return(obj.ToIntPtr() == ToIntPtr()); 
     91        } 
     92         
    8893        public static implicit operator IntPtr(AprArray array) 
    8994        { 
     
    149154        { 
    150155            if(list is AprArray) 
    151                 //return(((AprArray)list).Copy(pool)); 
    152                 return (AprArray)list; 
     156                return(((AprArray)list).Copy(pool)); 
    153157            else 
    154158            { 
     
    165169            } 
    166170        } 
    167          
     171 
     172        public static AprArray CastMake(AprPool pool, ICollection list ) 
     173        { 
     174            if(list is AprArray) 
     175            { 
     176                if( ((AprArray)list).Pool.ReferenceEquals(pool) ) 
     177                    return ((AprArray)list);     
     178            } 
     179            return( Make(pool, list) ); 
     180        } 
     181                         
    168182        public AprArray Copy(AprPool pool) 
    169183        { 
  • trunk/AprSharp/dev/src/AprFile.cs

    r43 r45  
    9292        } 
    9393 
     94        public bool ReferenceEquals(IAprUnmanaged obj) 
     95        { 
     96            return(obj.ToIntPtr() == ToIntPtr()); 
     97        } 
     98         
    9499        public static implicit operator IntPtr(AprFile file) 
    95100        { 
  • trunk/AprSharp/dev/src/AprHash.cs

    r43 r45  
    5050        } 
    5151 
     52        public bool ReferenceEquals(IAprUnmanaged obj) 
     53        { 
     54            return(obj.ToIntPtr() == ToIntPtr()); 
     55        } 
     56         
    5257        public static implicit operator IntPtr(AprHash hashIndex) 
    5358        { 
  • trunk/AprSharp/dev/src/AprHashIndex.cs

    r43 r45  
    5050        } 
    5151 
     52        public bool ReferenceEquals(IAprUnmanaged obj) 
     53        { 
     54            return(obj.ToIntPtr() == ToIntPtr()); 
     55        } 
     56         
    5257        public static implicit operator IntPtr(AprHashIndex hashIndex) 
    5358        { 
  • trunk/AprSharp/dev/src/AprMemNode.cs

    r43 r45  
    6565        } 
    6666 
     67        public bool ReferenceEquals(IAprUnmanaged obj) 
     68        { 
     69            return(obj.ToIntPtr() == ToIntPtr()); 
     70        } 
     71         
    6772        public static implicit operator IntPtr(AprMemNode memNode) 
    6873        { 
  • trunk/AprSharp/dev/src/AprPool.cs

    r43 r45  
    4949        } 
    5050 
     51        public bool ReferenceEquals(IAprUnmanaged obj) 
     52        { 
     53            return(obj.ToIntPtr() == ToIntPtr()); 
     54        } 
     55         
    5156        public static implicit operator IntPtr(AprPool pool) 
    5257        { 
  • trunk/AprSharp/dev/src/AprString.cs

    r43 r45  
    8181        } 
    8282 
     83        public bool ReferenceEquals(IAprUnmanaged obj) 
     84        { 
     85            return(obj.ToIntPtr() == ToIntPtr()); 
     86        } 
     87         
    8388        public static implicit operator IntPtr(AprString str) 
    8489        { 
  • trunk/AprSharp/dev/src/AprThreadMutex.cs

    r43 r45  
    5656        } 
    5757 
     58        public bool ReferenceEquals(IAprUnmanaged obj) 
     59        { 
     60            return(obj.ToIntPtr() == ToIntPtr()); 
     61        } 
     62         
    5863        public static implicit operator IntPtr(AprThreadMutex threadMutex) 
    5964        { 
  • trunk/AprSharp/dev/src/AprTimeExp.cs

    r43 r45  
    7777        } 
    7878 
     79        public bool ReferenceEquals(IAprUnmanaged obj) 
     80        { 
     81            return(obj.ToIntPtr() == ToIntPtr()); 
     82        } 
     83         
    7984        public static implicit operator IntPtr(AprTimeExp timeExp) 
    8085        { 
  • trunk/AprSharp/dev/src/IAprUnmanaged.cs

    r43 r45  
    2424 
    2525        void ClearPtr(); 
     26         
     27        bool ReferenceEquals(IAprUnmanaged obj);         
    2628    }  
    2729} 
  • trunk/AprSharp/test/src/AprArrayTest.cs

    r43 r45  
    262262            a.CopyTo(arr,0); 
    263263             
     264            AprArray b = AprArray.CastMake(p,a); 
     265            Assert.AreEqual(a.ToIntPtr(),b.ToIntPtr(),"#F19"); 
     266             
     267            AprPool sp = AprPool.Create(p); 
     268            Assert.IsFalse(sp.IsNull,"#F01"); 
     269            b = AprArray.CastMake(sp,a); 
     270            Assert.IsFalse(a.ToIntPtr() == b.ToIntPtr(),"#F20"); 
     271 
    264272            Assert.AreEqual("5",a.PopObject().ToString(),"#F03"); 
    265273            Assert.AreEqual("4",a.PopObject().ToString(),"#F04"); 
     
    267275            Assert.AreEqual("2",a.PopObject().ToString(),"#F06"); 
    268276            Assert.AreEqual("1",a.PopObject().ToString(),"#F07"); 
     277             
     278            Assert.AreEqual("5",b.PopObject().ToString(),"#F21"); 
     279            Assert.AreEqual("4",b.PopObject().ToString(),"#F22"); 
     280            Assert.AreEqual("3",b.PopObject().ToString(),"#F23"); 
     281            Assert.AreEqual("2",b.PopObject().ToString(),"#F24"); 
     282            Assert.AreEqual("1",b.PopObject().ToString(),"#F25"); 
    269283             
    270284            Assert.AreEqual("1",arr[0].ToString(),"#F08");