Debian Codegraph @

src/smetana/core/size_t_struct.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 /**
40 * "Pseudo size" of a C structure. In C, this is the actual size of the structure. In Java, this is an indication to
41 * know which structure we are going to allocate.
42 *
43 * @author Arnaud Roques
44 *
45 */
46 public class size_t_struct implements size_t {
47
48 public final Class tobeAllocated;
49 private boolean positive = true;
50
51 public size_t_struct(Class tobeAllocated) {
52 this.tobeAllocated = tobeAllocated;
53 }
54
55
56 public size_t_struct negate() {
57 final size_t_struct result = new size_t_struct(tobeAllocated);
58 result.positive = !result.positive;
59 return result;
60 }
61
62
63 public size_t_struct multiply(int sz) {
64 throw new UnsupportedOperationException();
65 }
66
67 // @Override
68 // public String toString() {
69 // return super.toString() + " size_t(" + tobeAllocated + "*" + arraySize + ", bytes=" + bytes + ")";
70 // }
71
72 public boolean isStrictPositive() {
73 return positive;
74 }
75
76 public boolean isStrictNegative() {
77 return !positive;
78 }
79
80
81
82 public final Class getTobeAllocated() {
83 return tobeAllocated;
84 }
85
86 public __ptr__ malloc() {
87 if (tobeAllocated != null) {
88 return Memory.malloc(tobeAllocated);
89 }
90 return (__ptr__) new CObject(-1, tobeAllocated);
91 }
92
93 public size_t_struct plus(int strlen) {
94 // throw new UnsupportedOperationException();
95 JUtils.LOG("adding " + strlen + " to " + this);
96 return this;
97 }
98
99 public boolean isZero() {
100 return false;
101 }
102
103
104 public __ptr__ realloc(Object old) {
105 throw new UnsupportedOperationException();
106 }
107
108
109 public int getInternalNb() {
110 throw new UnsupportedOperationException();
111 }
112
113
114 }