Browse Source

Fix Itanium bugs introduced by commit 65edb53

pull/1/head
Alexander Corrado 16 years ago committed by Alex Corrado
parent
commit
2116e1f175
  1. 4
      src/Mono.VisualC.Interop/ABI/Impl/ItaniumTypeInfo.cs
  2. 45
      src/Mono.VisualC.Interop/Util/LazyGeneratedList.cs

4
src/Mono.VisualC.Interop/ABI/Impl/ItaniumTypeInfo.cs

@ -41,6 +41,8 @@ namespace Mono.VisualC.Interop.ABI {
hasVirtualDtor = true; hasVirtualDtor = true;
VirtualMethods.RemoveAt (i); VirtualMethods.RemoveAt (i);
VTableDelegateTypes.RemoveAt (i);
VTableOverrides.RemoveAt (i);
break; break;
} }
} }
@ -58,7 +60,7 @@ namespace Mono.VisualC.Interop.ABI {
return; return;
hasVirtualDtor |= ((ItaniumTypeInfo)baseType).HasVirtualDestructor; hasVirtualDtor |= ((ItaniumTypeInfo)baseType).HasVirtualDestructor;
base.AddBase (baseType); base.AddBase (baseType, false);
} }
// Itanium puts all its virtual dtors at the bottom of the vtable (2 slots each). // Itanium puts all its virtual dtors at the bottom of the vtable (2 slots each).

45
src/Mono.VisualC.Interop/Util/LazyGeneratedList.cs

@ -39,14 +39,18 @@ namespace Mono.VisualC.Interop.Util {
private LazyGeneratedList<TItem> previous; private LazyGeneratedList<TItem> previous;
private LazyGeneratedList<TItem> next; private LazyGeneratedList<TItem> next;
private int lead, follow; private int lead, content, follow;
private HashSet<int> removed;
public LazyGeneratedList (int count, Func<int, TItem> generator) public LazyGeneratedList (int count, Func<int, TItem> generator)
{ {
this.cache = new TItem [count]; this.cache = new TItem [count];
this.generator = generator; this.generator = generator;
this.lead = 0; this.lead = 0;
this.content = count;
this.follow = 0; this.follow = 0;
this.removed = new HashSet<int> ();
} }
public IEnumerator<TItem> GetEnumerator () public IEnumerator<TItem> GetEnumerator ()
@ -60,7 +64,7 @@ namespace Mono.VisualC.Interop.Util {
} }
public int Count { public int Count {
get { return lead + cache.Length + follow; } get { return lead + content + follow; }
} }
public bool IsReadOnly { public bool IsReadOnly {
@ -69,28 +73,33 @@ namespace Mono.VisualC.Interop.Util {
public TItem this [int index] { public TItem this [int index] {
get { get {
return ForIndex (index, i => previous [i], i => (cache [i] == null? (cache [i] = generator (i)) : cache [i]), i => next [i]);
}
set {
throw new NotSupportedException ("This IList is read only");
}
}
private TItem ForIndex (int index, Func<int,TItem> leadAction, Func<int,TItem> contentAction, Func<int,TItem> followAction)
{
if (removed.Contains (index))
index++;
if (index < lead) { if (index < lead) {
if (previous != null && index > 0) if (previous != null && index >= 0)
return previous [index]; return leadAction (index);
throw new IndexOutOfRangeException (index.ToString ()); throw new IndexOutOfRangeException (index.ToString ());
} }
int realIndex = index - lead; int realIndex = index - lead;
if (realIndex > cache.Length) { if (realIndex >= content) {
int followIndex = realIndex - cache.Length; int followIndex = realIndex - content;
if (next != null && followIndex < follow) if (next != null && followIndex < follow)
return next [followIndex]; return followAction (followIndex);
throw new IndexOutOfRangeException (index.ToString ()); throw new IndexOutOfRangeException (index.ToString ());
} }
if (cache [realIndex] == null) return contentAction (realIndex);
cache [realIndex] = generator (realIndex);
return cache [realIndex];
}
set {
throw new NotSupportedException ("This IList is read only");
}
} }
/* Visual aid for the behavior of the following methods: /* Visual aid for the behavior of the following methods:
@ -159,7 +168,11 @@ namespace Mono.VisualC.Interop.Util {
} }
public void RemoveAt (int index) public void RemoveAt (int index)
{ {
throw new NotImplementedException (); while (removed.Contains (index))
index++;
removed.Add (index);
content--;
} }
public void Add (TItem item) public void Add (TItem item)
{ {

Loading…
Cancel
Save