41package com.jogamp.gluegen.cgram.types;
43import com.jogamp.common.os.MachineDataInfo;
44import com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp;
52 static boolean relaxedEqSem =
false;
53 private final boolean fixedNativeSize;
60 private SizeThunk(
final boolean fixedNativeSize) {
61 this.fixedNativeSize = fixedNativeSize;
68 }
catch (
final CloneNotSupportedException ex) {
69 throw new InternalError();
80 final int hash = 0x02DEAD6F;
81 return ((hash << 5) - hash) + hashCodeImpl();
83 abstract int hashCodeImpl();
86 public final boolean equals(
final Object arg) {
89 }
else if ( !(arg instanceof
SizeThunk) ) {
93 return hashCodeImpl() == t.hashCodeImpl();
99 final int hash = 0x01DEAD5F;
100 return ((hash << 5) - hash) + hashCodeSemanticsImpl();
102 abstract int hashCodeSemanticsImpl();
108 }
else if ( !(arg instanceof
SizeThunk) ) {
112 return hashCodeSemanticsImpl() == t.hashCodeSemanticsImpl();
116 static final int magic_int08 = 0x00000010;
117 static final int magic_int16 = 0x00000012;
118 static final int magic_int32 = 0x00000014;
119 static final int magic_intxx = 0x00000016;
120 static final int magic_long64 = 0x00000020;
121 static final int magic_longxx = 0x00000022;
122 static final int magic_float32 = 0x00000030;
123 static final int magic_float64 = 0x00000032;
124 static final int magic_aptr64 = 0x00000040;
125 static final int magic_ops = 0x00010000;
130 return machDesc.int8SizeInBytes();
134 return machDesc.int8AlignmentInBytes();
137 protected int hashCodeImpl() {
return 1; }
139 protected int hashCodeSemanticsImpl() {
return relaxedEqSem ? magic_int32 : magic_int08; }
145 return machDesc.int16SizeInBytes();
149 return machDesc.int16AlignmentInBytes();
152 protected int hashCodeImpl() {
return 2; }
154 protected int hashCodeSemanticsImpl() {
return relaxedEqSem ? magic_int32 : magic_int16; }
160 return machDesc.int32SizeInBytes();
164 return machDesc.int32AlignmentInBytes();
167 protected int hashCodeImpl() {
return 3; }
169 protected int hashCodeSemanticsImpl() {
return magic_int32; }
175 return machDesc.intSizeInBytes();
179 return machDesc.intAlignmentInBytes();
182 protected int hashCodeImpl() {
return 4; }
184 protected int hashCodeSemanticsImpl() {
return relaxedEqSem ? magic_int32 : magic_intxx; }
190 return machDesc.longSizeInBytes();
194 return machDesc.longAlignmentInBytes();
197 protected int hashCodeImpl() {
return 5; }
199 protected int hashCodeSemanticsImpl() {
return relaxedEqSem ? magic_long64 : magic_longxx; }
205 return machDesc.int64SizeInBytes();
209 return machDesc.int64AlignmentInBytes();
212 protected int hashCodeImpl() {
return 6; }
214 protected int hashCodeSemanticsImpl() {
return magic_long64; }
220 return machDesc.floatSizeInBytes();
224 return machDesc.floatAlignmentInBytes();
227 protected int hashCodeImpl() {
return 7; }
229 protected int hashCodeSemanticsImpl() {
return magic_float32; }
235 return machDesc.doubleSizeInBytes();
239 return machDesc.doubleAlignmentInBytes();
242 protected int hashCodeImpl() {
return 8; }
244 protected int hashCodeSemanticsImpl() {
return magic_float64; }
250 return machDesc.pointerSizeInBytes();
254 return machDesc.pointerAlignmentInBytes();
257 protected int hashCodeImpl() {
return 9; }
259 protected int hashCodeSemanticsImpl() {
return magic_aptr64; }
275 return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ;
278 protected int hashCodeImpl() {
281 hash = ((hash << 5) - hash) + (
null != thunk1 ? thunk1.
hashCode() : 0 );
282 return ((hash << 5) - hash) + (
null != thunk2 ? thunk2.
hashCode() : 0 );
285 protected int hashCodeSemanticsImpl() {
return magic_ops + 1; }
300 return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ;
303 protected int hashCodeImpl() {
306 hash = ((hash << 5) - hash) + (
null != thunk1 ? thunk1.
hashCode() : 0 );
307 return ((hash << 5) - hash) + (
null != thunk2 ? thunk2.
hashCode() : 0 );
310 protected int hashCodeSemanticsImpl() {
return magic_ops + 2; }
336 final long net_size = offsetThunk.
computeSize(machDesc);
343 final long padding = ( alignment - ( net_size & ( alignment - 1 ) ) ) & ( alignment - 1 );
344 return net_size + padding;
351 return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ;
354 protected int hashCodeImpl() {
357 hash = ((hash << 5) - hash) + (
null != offsetThunk ? offsetThunk.
hashCode() : 0 );
358 return ((hash << 5) - hash) + (
null != alignmentThunk ? alignmentThunk.
hashCode() : 0 );
361 protected int hashCodeSemanticsImpl() {
return magic_ops + 3; }
376 return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ;
379 protected int hashCodeImpl() {
382 hash = ((hash << 5) - hash) + (
null != thunk1 ? thunk1.
hashCode() : 0 );
383 return ((hash << 5) - hash) + (
null != thunk2 ? thunk2.
hashCode() : 0 );
386 protected int hashCodeSemanticsImpl() {
return magic_ops + 4; }
401 protected int hashCodeImpl() {
403 final int hash = 31 + 14;
404 return ((hash << 5) - hash) +
constant;
407 protected int hashCodeSemanticsImpl() {
return magic_ops + 5; }
Machine data description for alignment and size onle, see com.jogamp.gluegen.
Provides a level of indirection between the definition of a type's size and the absolute value of thi...
final boolean equals(final Object arg)
static final SizeThunk INT8
abstract long computeAlignment(MachineDataInfo machDesc)
static SizeThunk max(final SizeThunk thunk1, final SizeThunk thunk2)
final boolean hasFixedNativeSize()
final boolean equalSemantics(final SemanticEqualityOp arg)
Semantic equality test for Types exclusive its given name.
abstract long computeSize(MachineDataInfo machDesc)
static final SizeThunk DOUBLE
static SizeThunk add(final SizeThunk thunk1, final SizeThunk thunk2)
static final SizeThunk INT32
static void setRelaxedEqualSemanticsTest(final boolean v)
static SizeThunk constant(final int constant)
static SizeThunk mul(final SizeThunk thunk1, final SizeThunk thunk2)
static final SizeThunk POINTER
static final SizeThunk LONG
static final SizeThunk INT64
static SizeThunk align(final SizeThunk offsetThunk, final SizeThunk alignmentThunk)
final int hashCodeSemantics()
Semantic hashcode for Types exclusive its given name.
static final SizeThunk FLOAT
static final SizeThunk INT16
static final SizeThunk INTxx
Supports semantic equality and hash functions for types.