| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
package smetana.core; |
| 38 |
|
| 39 |
import java.util.ArrayList; |
| 40 |
import java.util.List; |
| 41 |
|
| 42 |
import smetana.core.amiga.Area; |
| 43 |
import smetana.core.amiga.BuilderArea; |
| 44 |
import smetana.core.amiga.Counter; |
| 45 |
|
| 46 |
public class __array_of_cstring_impl__ implements __array_of_cstring__ { |
| 47 |
|
| 48 |
private final List<Area> data; |
| 49 |
private final int currentPos; |
| 50 |
|
| 51 |
private final int UID = Counter.CPT++; |
| 52 |
|
| 53 |
public String getUID36() { |
| 54 |
return Integer.toString(UID, 36); |
| 55 |
} |
| 56 |
|
| 57 |
public void swap(int i, int j) { |
| 58 |
Area e1 = data.get(i); |
| 59 |
Area e2 = data.get(j); |
| 60 |
data.set(i, e2); |
| 61 |
data.set(j, e1); |
| 62 |
} |
| 63 |
|
| 64 |
@Override |
| 65 |
public String toString() { |
| 66 |
if (data.get(0) != null) { |
| 67 |
return "__array__ " + getUID36() + " " + currentPos + "/" + data.size() + " " + data.get(0).toString(); |
| 68 |
} |
| 69 |
return "__array__ " + getUID36() + " " + currentPos + "/" + data.size(); |
| 70 |
} |
| 71 |
|
| 72 |
public void realloc(int nb) { |
| 73 |
while (data.size() < nb + currentPos) { |
| 74 |
data.add(null); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
public int comparePointerInternal(__array_of_cstring__ other2) { |
| 83 |
__array_of_cstring_impl__ other = (__array_of_cstring_impl__) other2; |
| 84 |
if (this.data != other.data) { |
| 85 |
throw new IllegalArgumentException(); |
| 86 |
} |
| 87 |
return this.currentPos - other.currentPos; |
| 88 |
} |
| 89 |
|
| 90 |
public static __array_of_cstring_impl__ mallocStarChar(int nb) { |
| 91 |
return new __array_of_cstring_impl__(nb, new BuilderArea() { |
| 92 |
public Area createArea() { |
| 93 |
return null; |
| 94 |
} |
| 95 |
}); |
| 96 |
} |
| 97 |
|
| 98 |
private __array_of_cstring_impl__(List<Area> data, int currentPos) { |
| 99 |
this.data = data; |
| 100 |
this.currentPos = currentPos; |
| 101 |
check(); |
| 102 |
} |
| 103 |
|
| 104 |
private __array_of_cstring_impl__(int size, BuilderArea builder) { |
| 105 |
this.data = new ArrayList<Area>(); |
| 106 |
this.currentPos = 0; |
| 107 |
for (int i = 0; i < size; i++) { |
| 108 |
final Area tmp = builder.createArea(); |
| 109 |
data.add(tmp); |
| 110 |
} |
| 111 |
check(); |
| 112 |
} |
| 113 |
|
| 114 |
private void check() { |
| 115 |
if (getUID36().equals("194")) { |
| 116 |
JUtils.LOG("It's me"); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
public __array_of_cstring_impl__ move(int delta) { |
| 121 |
return new __array_of_cstring_impl__(data, currentPos + delta); |
| 122 |
} |
| 123 |
|
| 124 |
public __array_of_cstring_impl__ plus(int delta) { |
| 125 |
return move(delta); |
| 126 |
} |
| 127 |
|
| 128 |
public Area getInternal(int idx) { |
| 129 |
return data.get(idx + currentPos); |
| 130 |
} |
| 131 |
|
| 132 |
public void setInternalByIndex(int idx, Area value) { |
| 133 |
if (value == this) { |
| 134 |
throw new IllegalArgumentException(); |
| 135 |
} |
| 136 |
if (value instanceof __array_of_cstring_impl__) { |
| 137 |
throw new IllegalArgumentException(); |
| 138 |
} |
| 139 |
data.set(idx + currentPos, value); |
| 140 |
} |
| 141 |
|
| 142 |
public void memcopyFrom(Area source) { |
| 143 |
throw new UnsupportedOperationException(); |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
} |