Debian Codegraph @

src/smetana/core/__array_of_cstring_impl__.java

raw symbols SCIP
1 /* ========================================================================
2 * PlantUML : a free UML diagram generator
3 * ========================================================================
4 *
5 * Project Info: http://plantuml.com
6 *
7 * If you like this project or if you find it useful, you can support us at:
8 *
9 * http://plantuml.com/patreon (only 1$ per month!)
10 * http://plantuml.com/paypal
11 *
12 * This file is part of Smetana.
13 * Smetana is a partial translation of Graphviz/Dot sources from C to Java.
14 *
15 * (C) Copyright 2009-2020, Arnaud Roques
16 *
17 * This translation is distributed under the same Licence as the original C program.
18 *
19 * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
20 * LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
21 *
22 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
23 * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
24 *
25 * You may obtain a copy of the License at
26 *
27 * http://www.eclipse.org/legal/epl-v10.html
28 *
29 * Unless required by applicable law or agreed to in writing, software
30 * distributed under the License is distributed on an "AS IS" BASIS,
31 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
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 // public __ptr__ asPtr() {
79 // return new StarArray(this);
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 }