Debian Codegraph @

src/h/ST_object_t.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 *************************************************************************
20 * Copyright (c) 2011 AT&T Intellectual Property
21 * All rights reserved. This program and the accompanying materials
22 * are made available under the terms of the Eclipse Public License v1.0
23 * which accompanies this distribution, and is available at
24 * http://www.eclipse.org/legal/epl-v10.html
25 *
26 * Contributors: See CVS logs. Details at http://www.graphviz.org/
27 *************************************************************************
28 *
29 * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
30 * LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
31 *
32 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
33 * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
34 *
35 * You may obtain a copy of the License at
36 *
37 * http://www.eclipse.org/legal/epl-v10.html
38 *
39 * Unless required by applicable law or agreed to in writing, software
40 * distributed under the License is distributed on an "AS IS" BASIS,
41 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 * See the License for the specific language governing permissions and
43 * limitations under the License.
44 *
45 */
46 package h;
47
48 import java.util.ArrayList;
49 import java.util.List;
50
51 import smetana.core.UnsupportedArrayOfStruct2;
52 import smetana.core.UnsupportedStructAndPtr;
53 import smetana.core.__array_of_ptr__;
54 import smetana.core.__ptr__;
55 import smetana.core.__struct__;
56 import smetana.core.size_t;
57 import smetana.core.amiga.StarStruct;
58
59 public class ST_object_t extends UnsupportedStructAndPtr implements ST_Node_t___or_object_t {
60
61 private final StarStruct parent;
62
63 public ST_object_t() {
64 this(null);
65 }
66
67 public ST_object_t(StarStruct parent) {
68 this.parent = parent;
69 }
70
71 // "typedef struct",
72 // "{",
73 public final ST_pointf pos = new ST_pointf(this);
74 public final ST_pointf sz = new ST_pointf(this);
75 // "xlabel_t *lbl",
76 public ST_xlabel_t.Array lbl;
77
78 // "}",
79 // "object_t");
80
81 @Override
82 public ST_object_t getStruct() {
83 return this;
84 }
85
86 @Override
87 public ST_object_t getPtr() {
88 return this;
89 }
90
91 @Override
92 public boolean isSameThan(StarStruct other) {
93 ST_object_t other2 = (ST_object_t) other;
94 return this == other2;
95 }
96
97 public static class Array extends UnsupportedArrayOfStruct2 implements __ptr__, __array_of_ptr__ {
98
99 private final List<ST_object_t> data;
100 private final int pos;
101
102 @Override
103 public Array asPtr() {
104 return this;
105 }
106
107 @Override
108 public ST_object_t getStruct() {
109 return get(0);
110 }
111
112
113 @Override
114 public __ptr__ setPtr(String fieldName, __ptr__ data) {
115 return get(0).setPtr(fieldName, data);
116 }
117
118 @Override
119 public void setStruct(String fieldName, __struct__ data) {
120 get(0).setStruct(fieldName, data);
121 }
122
123 public Array(int size) {
124 this.data = new ArrayList<ST_object_t>();
125 this.pos = 0;
126 for (int i = 0; i < size; i++) {
127 data.add(new ST_object_t());
128 }
129 }
130
131 public Array reallocJ(int newsize) {
132 while (data.size() < newsize) {
133 data.add(new ST_object_t());
134 }
135 return this;
136 }
137
138 public Array plus(int delta) {
139 return plusJ(delta);
140 }
141
142 private Array(List<ST_object_t> data, int pos) {
143 this.data = data;
144 this.pos = pos;
145 }
146
147 public ST_object_t get(int i) {
148 return this.data.get(pos + i);
149 }
150
151 public Array plusJ(int i) {
152 return new Array(data, pos + i);
153 }
154
155 public int minus(Array other) {
156 if (this.data != other.data) {
157 throw new IllegalArgumentException();
158 }
159 return this.pos - other.pos;
160 }
161
162 public Array move(int delta) {
163 throw new UnsupportedOperationException(getClass().toString());
164 }
165
166 public void realloc(size_t nb) {
167 throw new UnsupportedOperationException(getClass().toString());
168 }
169
170 public int comparePointerInternal(__array_of_ptr__ other) {
171 throw new UnsupportedOperationException(getClass().toString());
172 }
173
174
175 }
176
177 @Override
178 public __ptr__ setPtr(String fieldName, __ptr__ newData) {
179 if (fieldName.equals("pos")) {
180 this.pos.copyDataFrom(newData);
181 return newData;
182 }
183 if (fieldName.equals("lbl")) {
184 this.lbl = (ST_xlabel_t.Array) newData;
185 return this.lbl;
186 }
187 return super.setPtr(fieldName, newData);
188 }
189
190 @Override
191 public void setStruct(String fieldName, __struct__ newData) {
192 if (fieldName.equals("pos")) {
193 this.pos.copyDataFrom(newData);
194 return;
195 }
196 if (fieldName.equals("sz")) {
197 this.sz.copyDataFrom(newData);
198 return;
199 }
200 super.setStruct(fieldName, newData);
201 }
202
203 }
204
205 // typedef struct {
206 // pointf pos; /* Position of lower-left corner of object */
207 // pointf sz; /* Size of object; may be zero for a point */
208 // xlabel_t *lbl; /* Label attached to object, or NULL */
209 // } object_t;