summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp')
-rw-r--r--src/java/com/jogamp/gluegen/CMethodBindingEmitter.java4
-rw-r--r--src/java/com/jogamp/gluegen/DebugEmitter.java2
-rw-r--r--src/java/com/jogamp/gluegen/GlueEmitter.java2
-rw-r--r--src/java/com/jogamp/gluegen/GlueGen.java4
-rw-r--r--src/java/com/jogamp/gluegen/JavaConfiguration.java2
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java10
-rw-r--r--src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java11
-rw-r--r--src/java/com/jogamp/gluegen/JavaType.java1
-rw-r--r--src/java/com/jogamp/gluegen/MethodBinding.java2
-rw-r--r--src/java/com/jogamp/gluegen/ReferencedStructs.java4
-rw-r--r--src/java/com/jogamp/gluegen/SymbolFilter.java1
-rw-r--r--src/java/com/jogamp/gluegen/cgram/HeaderParser.g7
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/CompoundTypeKind.java50
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java3
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/TypeDictionary.java2
-rw-r--r--src/java/com/jogamp/gluegen/package.html8
-rwxr-xr-xsrc/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java2
-rwxr-xr-xsrc/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/ArrayType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/ArrayType.java)10
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/BitType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/BitType.java)2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/CVAttributes.java (renamed from src/java/com/jogamp/gluegen/cgram/types/CVAttributes.java)2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/CompoundType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/CompoundType.java)39
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/CompoundTypeKind.jav41
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/DoubleType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/DoubleType.java)2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/EnumType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/EnumType.java)2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/Field.java (renamed from src/java/com/jogamp/gluegen/cgram/types/Field.java)2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/FloatType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/FloatType.java)2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/FunctionType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/FunctionType.java)2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/IntType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/IntType.java)2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/MemoryLayoutType.java41
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/PointerType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/PointerType.java)2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/PrimitiveType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java)2
-rwxr-xr-xsrc/java/com/jogamp/gluegen/runtime/types/SizeThunk.java (renamed from src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java)61
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/StructLayout.java (renamed from src/java/com/jogamp/gluegen/StructLayout.java)101
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/StructType.java57
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/Type.java (renamed from src/java/com/jogamp/gluegen/cgram/types/Type.java)4
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/TypeVisitor.java (renamed from src/java/com/jogamp/gluegen/cgram/types/TypeVisitor.java)2
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/UnionType.java57
-rw-r--r--src/java/com/jogamp/gluegen/runtime/types/VoidType.java (renamed from src/java/com/jogamp/gluegen/cgram/types/VoidType.java)2
39 files changed, 344 insertions, 208 deletions
diff --git a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
index d47cded..1087d15 100644
--- a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
@@ -45,6 +45,10 @@ import java.text.MessageFormat;
import com.jogamp.common.os.MachineDescription;
import com.jogamp.gluegen.cgram.types.*;
+import com.jogamp.gluegen.runtime.types.ArrayType;
+import com.jogamp.gluegen.runtime.types.PointerType;
+import com.jogamp.gluegen.runtime.types.Type;
+
import java.util.logging.Logger;
import static java.util.logging.Level.*;
diff --git a/src/java/com/jogamp/gluegen/DebugEmitter.java b/src/java/com/jogamp/gluegen/DebugEmitter.java
index fc536c8..6afc55c 100644
--- a/src/java/com/jogamp/gluegen/DebugEmitter.java
+++ b/src/java/com/jogamp/gluegen/DebugEmitter.java
@@ -43,6 +43,8 @@ import java.util.*;
import com.jogamp.common.os.MachineDescription;
import com.jogamp.gluegen.cgram.types.*;
+import com.jogamp.gluegen.runtime.types.CompoundType;
+import com.jogamp.gluegen.runtime.types.Type;
/** Debug emitter which prints the parsing results to standard output. */
diff --git a/src/java/com/jogamp/gluegen/GlueEmitter.java b/src/java/com/jogamp/gluegen/GlueEmitter.java
index ed06b19..ac1065b 100644
--- a/src/java/com/jogamp/gluegen/GlueEmitter.java
+++ b/src/java/com/jogamp/gluegen/GlueEmitter.java
@@ -43,6 +43,8 @@ import java.util.*;
import com.jogamp.common.os.MachineDescription;
import com.jogamp.gluegen.cgram.types.*;
+import com.jogamp.gluegen.runtime.types.CompoundType;
+import com.jogamp.gluegen.runtime.types.Type;
/** Specifies the interface by which GlueGen requests glue code to be
generated. Can be replaced to generate glue code for other
diff --git a/src/java/com/jogamp/gluegen/GlueGen.java b/src/java/com/jogamp/gluegen/GlueGen.java
index c898058..9b0bb5f 100644
--- a/src/java/com/jogamp/gluegen/GlueGen.java
+++ b/src/java/com/jogamp/gluegen/GlueGen.java
@@ -52,6 +52,10 @@ import antlr.*;
import com.jogamp.gluegen.cgram.*;
import com.jogamp.gluegen.cgram.types.*;
import com.jogamp.gluegen.pcpp.*;
+import com.jogamp.gluegen.runtime.types.CompoundType;
+import com.jogamp.gluegen.runtime.types.EnumType;
+import com.jogamp.gluegen.runtime.types.PointerType;
+import com.jogamp.gluegen.runtime.types.Type;
import static java.lang.System.*;
diff --git a/src/java/com/jogamp/gluegen/JavaConfiguration.java b/src/java/com/jogamp/gluegen/JavaConfiguration.java
index 5323c77..90160f6 100644
--- a/src/java/com/jogamp/gluegen/JavaConfiguration.java
+++ b/src/java/com/jogamp/gluegen/JavaConfiguration.java
@@ -49,7 +49,9 @@ import java.util.Map.Entry;
import java.util.regex.*;
import com.jogamp.gluegen.jgram.*;
+import com.jogamp.gluegen.runtime.types.Type;
import com.jogamp.gluegen.cgram.types.*;
+
import java.util.logging.Logger;
import static java.util.logging.Level.*;
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index d92e589..a3ee962 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -49,6 +49,14 @@ import java.util.*;
import java.text.MessageFormat;
import com.jogamp.gluegen.cgram.types.*;
+import com.jogamp.gluegen.runtime.types.CompoundType;
+import com.jogamp.gluegen.runtime.types.Field;
+import com.jogamp.gluegen.runtime.types.FunctionType;
+import com.jogamp.gluegen.runtime.types.PointerType;
+import com.jogamp.gluegen.runtime.types.SizeThunk;
+import com.jogamp.gluegen.runtime.types.StructLayout;
+import com.jogamp.gluegen.runtime.types.Type;
+
import java.nio.Buffer;
import java.util.logging.Logger;
@@ -1424,7 +1432,7 @@ public class JavaEmitter implements GlueEmitter {
private StructLayout getLayout() {
if (layout == null) {
- layout = StructLayout.createForCurrentPlatform();
+ layout = StructLayout.create(0);
}
return layout;
}
diff --git a/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
index ce1acc2..b1512e3 100644
--- a/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaMethodBindingEmitter.java
@@ -40,11 +40,12 @@
package com.jogamp.gluegen;
import com.jogamp.gluegen.cgram.HeaderParser;
-import com.jogamp.gluegen.cgram.types.ArrayType;
-import com.jogamp.gluegen.cgram.types.CompoundType;
-import com.jogamp.gluegen.cgram.types.EnumType;
-import com.jogamp.gluegen.cgram.types.PointerType;
-import com.jogamp.gluegen.cgram.types.Type;
+import com.jogamp.gluegen.runtime.types.ArrayType;
+import com.jogamp.gluegen.runtime.types.CompoundType;
+import com.jogamp.gluegen.runtime.types.EnumType;
+import com.jogamp.gluegen.runtime.types.PointerType;
+import com.jogamp.gluegen.runtime.types.Type;
+
import java.io.PrintWriter;
import java.text.MessageFormat;
import java.util.List;
diff --git a/src/java/com/jogamp/gluegen/JavaType.java b/src/java/com/jogamp/gluegen/JavaType.java
index 04d14de..1c1213e 100644
--- a/src/java/com/jogamp/gluegen/JavaType.java
+++ b/src/java/com/jogamp/gluegen/JavaType.java
@@ -43,6 +43,7 @@ package com.jogamp.gluegen;
import java.nio.*;
import com.jogamp.gluegen.cgram.types.*;
+import com.jogamp.gluegen.runtime.types.Type;
/**
* Describes a java-side representation of a type that is used to represent
diff --git a/src/java/com/jogamp/gluegen/MethodBinding.java b/src/java/com/jogamp/gluegen/MethodBinding.java
index a8d4b30..22625a1 100644
--- a/src/java/com/jogamp/gluegen/MethodBinding.java
+++ b/src/java/com/jogamp/gluegen/MethodBinding.java
@@ -40,7 +40,7 @@
package com.jogamp.gluegen;
import com.jogamp.gluegen.cgram.types.FunctionSymbol;
-import com.jogamp.gluegen.cgram.types.Type;
+import com.jogamp.gluegen.runtime.types.Type;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/src/java/com/jogamp/gluegen/ReferencedStructs.java b/src/java/com/jogamp/gluegen/ReferencedStructs.java
index b8a176f..c00653d 100644
--- a/src/java/com/jogamp/gluegen/ReferencedStructs.java
+++ b/src/java/com/jogamp/gluegen/ReferencedStructs.java
@@ -41,6 +41,10 @@ package com.jogamp.gluegen;
import java.util.*;
import com.jogamp.gluegen.cgram.types.*;
+import com.jogamp.gluegen.runtime.types.CompoundType;
+import com.jogamp.gluegen.runtime.types.PointerType;
+import com.jogamp.gluegen.runtime.types.Type;
+import com.jogamp.gluegen.runtime.types.TypeVisitor;
public class ReferencedStructs implements TypeVisitor {
diff --git a/src/java/com/jogamp/gluegen/SymbolFilter.java b/src/java/com/jogamp/gluegen/SymbolFilter.java
index 4e99caa..724ff40 100644
--- a/src/java/com/jogamp/gluegen/SymbolFilter.java
+++ b/src/java/com/jogamp/gluegen/SymbolFilter.java
@@ -34,6 +34,7 @@
package com.jogamp.gluegen;
import com.jogamp.gluegen.cgram.types.FunctionSymbol;
+
import java.util.List;
/** Provides a mechanism by which the GlueEmitter can look at all of
diff --git a/src/java/com/jogamp/gluegen/cgram/HeaderParser.g b/src/java/com/jogamp/gluegen/cgram/HeaderParser.g
index 8c2ad26..6a78e91 100644
--- a/src/java/com/jogamp/gluegen/cgram/HeaderParser.g
+++ b/src/java/com/jogamp/gluegen/cgram/HeaderParser.g
@@ -46,6 +46,7 @@ header {
import antlr.CommonAST;
import com.jogamp.gluegen.cgram.types.*;
+ import com.jogamp.gluegen.runtime.types.*;
}
class HeaderParser extends GnuCTreeParser;
@@ -130,7 +131,7 @@ options {
int cvAttrs) {
CompoundType t = (CompoundType) structDictionary.get(typeName);
if (t == null) {
- t = new CompoundType(null, null, kind, cvAttrs);
+ t = CompoundType.create(null, null, kind, cvAttrs);
t.setStructName(typeName);
structDictionary.put(typeName, t);
}
@@ -297,8 +298,6 @@ options {
private void handleArrayExpr(TypeBox tb, AST t) {
if (t != null) {
try {
- // FIXME: this doesn't take into account struct alignment, which may be necessary
- // See also FIXMEs in ArrayType.java
int len = parseIntConstExpr(t);
tb.setType(canonicalize(new ArrayType(tb.type(), SizeThunk.mul(SizeThunk.constant(len), tb.type().getSize()), len, 0)));
return;
@@ -556,7 +555,7 @@ structOrUnionBody[CompoundTypeKind kind, int cvAttrs] returns [CompoundType t] {
t = (CompoundType) canonicalize(lookupInStructDictionary(id.getText(), kind, cvAttrs));
} ( structDeclarationList[t] )?
RCURLY { t.setBodyParsed(); }
- | LCURLY { t = new CompoundType(null, null, kind, cvAttrs); }
+ | LCURLY { t = CompoundType.create(null, null, kind, cvAttrs); }
( structDeclarationList[t] )?
RCURLY { t.setBodyParsed(); }
| id2:ID { t = (CompoundType) canonicalize(lookupInStructDictionary(id2.getText(), kind, cvAttrs)); }
diff --git a/src/java/com/jogamp/gluegen/cgram/types/CompoundTypeKind.java b/src/java/com/jogamp/gluegen/cgram/types/CompoundTypeKind.java
deleted file mode 100644
index b07611c..0000000
--- a/src/java/com/jogamp/gluegen/cgram/types/CompoundTypeKind.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any kind. ALL
- * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
- * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
- * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
- * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
- * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
- * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
- * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
- * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed or intended for use
- * in the design, construction, operation or maintenance of any nuclear
- * facility.
- *
- * Sun gratefully acknowledges that this software was originally authored
- * and developed by Kenneth Bradley Russell and Christopher John Kline.
- */
-
-package com.jogamp.gluegen.cgram.types;
-
-/** Type-safe enum for discriminating between structs and unions,
- which are both represented as compound types. */
-
-public class CompoundTypeKind {
- public static final CompoundTypeKind STRUCT = new CompoundTypeKind();
- public static final CompoundTypeKind UNION = new CompoundTypeKind();
-
- private CompoundTypeKind() {}
-}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java b/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java
index 545a6e8..2bfc859 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/FunctionSymbol.java
@@ -38,6 +38,9 @@
*/
package com.jogamp.gluegen.cgram.types;
+import com.jogamp.gluegen.runtime.types.FunctionType;
+import com.jogamp.gluegen.runtime.types.Type;
+
/** Describes a function symbol, which includes the name and
type. Since we are currently only concerned with processing
functions this is the only symbol type, though plausibly more
diff --git a/src/java/com/jogamp/gluegen/cgram/types/TypeDictionary.java b/src/java/com/jogamp/gluegen/cgram/types/TypeDictionary.java
index 3bc4d87..2e2caba 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/TypeDictionary.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/TypeDictionary.java
@@ -41,6 +41,8 @@ package com.jogamp.gluegen.cgram.types;
import java.util.*;
+import com.jogamp.gluegen.runtime.types.Type;
+
/** Utility class for recording names of typedefs and structs. */
public class TypeDictionary {
diff --git a/src/java/com/jogamp/gluegen/package.html b/src/java/com/jogamp/gluegen/package.html
index 5e86aad..cc97ad5 100644
--- a/src/java/com/jogamp/gluegen/package.html
+++ b/src/java/com/jogamp/gluegen/package.html
@@ -54,12 +54,12 @@
</ul>
<h5>Simple alignment arithmetic</h5>
- <blockquote>remainder = net_size % alignment</blockquote>
+ <blockquote>remainder = offset % alignment</blockquote>
since alignment is a multiple of 2 <code>-> x % 2n == x & (2n - 1)</code><br>
- <blockquote>remainder = net_size & ( alignment - 1 )</blockquote>
+ <blockquote>remainder = offset & ( alignment - 1 )</blockquote>
<blockquote>
- padding = alignment - remainder ;<br>
- aligned_size = net_size + padding ;
+ padding = (remainder > 0) ? alignment - remainder : 0 ;<br>
+ aligned_offset = offset + padding ;
</blockquote>
<h5>Type Size &amp; Alignment for x86, x86_64, armv7l-32bit-eabi and Window(mingw/mingw64)</h5>
diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
index fedb1e6..cdc15d0 100755
--- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
@@ -45,6 +45,8 @@ import com.jogamp.gluegen.JavaType;
import java.io.*;
import com.jogamp.gluegen.*;
import com.jogamp.gluegen.cgram.types.*;
+import com.jogamp.gluegen.runtime.types.PointerType;
+import com.jogamp.gluegen.runtime.types.Type;
public class ProcAddressCMethodBindingEmitter extends CMethodBindingEmitter {
diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
index c07dab7..6e15f8d 100755
--- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
+++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java
@@ -51,6 +51,8 @@ import java.util.*;
import com.jogamp.gluegen.*;
import com.jogamp.gluegen.cgram.types.*;
import com.jogamp.gluegen.runtime.*;
+import com.jogamp.gluegen.runtime.types.FunctionType;
+import com.jogamp.gluegen.runtime.types.Type;
/**
* A subclass of JavaEmitter that modifies the normal emission of C
diff --git a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java b/src/java/com/jogamp/gluegen/runtime/types/ArrayType.java
index 675efb5..ace3ff0 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/ArrayType.java
@@ -38,14 +38,14 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
/** Represents an array type. This differs from a pointer type in C
syntax by the use of "[]" rather than "*". The length may or may
not be known; if the length is unknown then a negative number
should be passed in to the constructor. */
-public class ArrayType extends Type implements Cloneable {
+public class ArrayType extends MemoryLayoutType implements Cloneable {
private Type elementType;
private int length;
private String computedName;
@@ -96,14 +96,12 @@ public class ArrayType extends Type implements Cloneable {
}
/** Recompute the size of this array if necessary. This needs to be
- done when the base element type is a compound type. */
- public void recomputeSize() {
+ done when the base element type is a compound type after layouting. */
+ void recomputeSize() {
ArrayType arrayElementType = getElementType().asArray();
if (arrayElementType != null) {
arrayElementType.recomputeSize();
}
- // FIXME: this doesn't take into account struct alignment, which may be necessary
- // See also FIXME below and in HeaderParser.g
super.setSize(SizeThunk.mul(SizeThunk.constant(getLength()), elementType.getSize()));
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/BitType.java b/src/java/com/jogamp/gluegen/runtime/types/BitType.java
index a7a1f55..78290d8 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/BitType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/BitType.java
@@ -38,7 +38,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
/** Represents a bitfield in a struct. */
diff --git a/src/java/com/jogamp/gluegen/cgram/types/CVAttributes.java b/src/java/com/jogamp/gluegen/runtime/types/CVAttributes.java
index 34b703e..f55f817 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/CVAttributes.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/CVAttributes.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
/** Enumeration for const/volatile attributes. These are passed in to
the constructor of the type. */
diff --git a/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java b/src/java/com/jogamp/gluegen/runtime/types/CompoundType.java
index 9e9ead7..3e93fcf 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/CompoundType.java
@@ -38,7 +38,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
import java.util.*;
@@ -46,8 +46,7 @@ import java.util.*;
and unions. The boolean type accessors indicate how the type is
really defined. */
-public class CompoundType extends Type implements Cloneable {
- private CompoundTypeKind kind;
+public abstract class CompoundType extends MemoryLayoutType implements Cloneable {
// The name "foo" in the construct "struct foo { ... }";
private String structName;
private ArrayList<Field> fields;
@@ -56,17 +55,22 @@ public class CompoundType extends Type implements Cloneable {
private boolean computedHashcode;
private int hashcode;
- public CompoundType(String name, SizeThunk size, CompoundTypeKind kind, int cvAttributes) {
- this(name, size, kind, cvAttributes, null);
- }
-
- private CompoundType(String name, SizeThunk size, CompoundTypeKind kind, int cvAttributes, String structName) {
+ CompoundType(String name, SizeThunk size, int cvAttributes, String structName) {
super(name, size, cvAttributes);
- assert kind != null;
- this.kind = kind;
this.structName = structName;
}
+ public static CompoundType create(String name, SizeThunk size, CompoundTypeKind kind, int cvAttributes) {
+ switch (kind) {
+ case STRUCT:
+ return new StructType(name, size, cvAttributes);
+ case UNION:
+ return new UnionType(name, size, cvAttributes);
+ default:
+ throw new RuntimeException("OO relation "+kind+" / Compount not yet supported");
+ }
+ }
+
public Object clone() {
CompoundType n = (CompoundType) super.clone();
if(null!=this.fields) {
@@ -103,7 +107,7 @@ public class CompoundType extends Type implements Cloneable {
return super.equals(arg) &&
((structName == null ? t.structName == null : structName.equals(t.structName)) ||
(structName != null && structName.equals(t.structName))) &&
- kind == t.kind && listsEqual(fields, t.fields);
+ listsEqual(fields, t.fields);
}
/** Returns the struct name of this CompoundType, i.e. the "foo" in
@@ -126,6 +130,9 @@ public class CompoundType extends Type implements Cloneable {
@Override
public CompoundType asCompound() { return this; }
+ ArrayList<Field> getFields() { return fields; }
+ void setFields(ArrayList<Field> fields) { this.fields = fields; }
+
/** Returns the number of fields in this type. */
public int getNumFields() {
return ((fields == null) ? 0 : fields.size());
@@ -154,9 +161,9 @@ public class CompoundType extends Type implements Cloneable {
}
/** Indicates whether this type was declared as a struct. */
- public boolean isStruct() { return (kind == CompoundTypeKind.STRUCT); }
+ public abstract boolean isStruct();
/** Indicates whether this type was declared as a union. */
- public boolean isUnion() { return (kind == CompoundTypeKind.UNION); }
+ public abstract boolean isUnion();
@Override
public String toString() {
@@ -212,10 +219,4 @@ public class CompoundType extends Type implements Cloneable {
visiting = false;
}
}
-
- Type newCVVariant(int cvAttributes) {
- CompoundType t = new CompoundType(getName(), getSize(), kind, cvAttributes, structName);
- t.fields = fields;
- return t;
- }
}
diff --git a/src/java/com/jogamp/gluegen/runtime/types/CompoundTypeKind.jav b/src/java/com/jogamp/gluegen/runtime/types/CompoundTypeKind.jav
new file mode 100644
index 0000000..96a07ae
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/types/CompoundTypeKind.jav
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package com.jogamp.gluegen.runtime.types;
+
+/** Type-safe enum for discriminating between structs and unions
+ represented as compound types. Used while syntax parsing. */
+public enum CompoundTypeKind {
+ STRUCT(0), UNION(1);
+
+ public final int id;
+
+ CompoundTypeKind(int id){
+ this.id = id;
+ }
+}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/DoubleType.java b/src/java/com/jogamp/gluegen/runtime/types/DoubleType.java
index 280485a..a18e4cc 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/DoubleType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/DoubleType.java
@@ -37,7 +37,7 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
/** Represents a double-word floating-point type (C type "double".) */
public class DoubleType extends PrimitiveType implements Cloneable {
diff --git a/src/java/com/jogamp/gluegen/cgram/types/EnumType.java b/src/java/com/jogamp/gluegen/runtime/types/EnumType.java
index 7967ba0..9bff00e 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/EnumType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/EnumType.java
@@ -37,7 +37,7 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
import java.util.ArrayList;
import java.util.NoSuchElementException;
diff --git a/src/java/com/jogamp/gluegen/cgram/types/Field.java b/src/java/com/jogamp/gluegen/runtime/types/Field.java
index 891bb27..0613b5f 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/Field.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/Field.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
import com.jogamp.common.os.MachineDescription;
diff --git a/src/java/com/jogamp/gluegen/cgram/types/FloatType.java b/src/java/com/jogamp/gluegen/runtime/types/FloatType.java
index 7766b8c..4a10210 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/FloatType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/FloatType.java
@@ -38,7 +38,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
/** Represents a single-word floating-point type (C type "float".) */
diff --git a/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java b/src/java/com/jogamp/gluegen/runtime/types/FunctionType.java
index cb430db..bfe0275 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/FunctionType.java
@@ -37,7 +37,7 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
import java.util.*;
diff --git a/src/java/com/jogamp/gluegen/cgram/types/IntType.java b/src/java/com/jogamp/gluegen/runtime/types/IntType.java
index b85c7fc..02ab530 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/IntType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/IntType.java
@@ -37,7 +37,7 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
public class IntType extends PrimitiveType implements Cloneable {
diff --git a/src/java/com/jogamp/gluegen/runtime/types/MemoryLayoutType.java b/src/java/com/jogamp/gluegen/runtime/types/MemoryLayoutType.java
new file mode 100644
index 0000000..3473d95
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/types/MemoryLayoutType.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.gluegen.runtime.types;
+
+public abstract class MemoryLayoutType extends Type {
+ private boolean isLayouted;
+
+ protected MemoryLayoutType(String name, SizeThunk size, int cvAttributes) {
+ super(name, size, cvAttributes);
+ isLayouted = false;
+ }
+
+ public boolean isLayouted() { return isLayouted; }
+ public void setLayouted() { /* FIXME JAU isLayouted = true; */ }
+
+}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java b/src/java/com/jogamp/gluegen/runtime/types/PointerType.java
index 4666e48..e45b9ff 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/PointerType.java
@@ -37,7 +37,7 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
public class PointerType extends Type implements Cloneable {
diff --git a/src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java b/src/java/com/jogamp/gluegen/runtime/types/PrimitiveType.java
index 1eea9a4..b2e6fc0 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/PrimitiveType.java
@@ -37,7 +37,7 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
public abstract class PrimitiveType extends Type implements Cloneable {
diff --git a/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java b/src/java/com/jogamp/gluegen/runtime/types/SizeThunk.java
index d71445d..b9d4eda 100755
--- a/src/java/com/jogamp/gluegen/cgram/types/SizeThunk.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/SizeThunk.java
@@ -38,7 +38,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
import com.jogamp.common.os.MachineDescription;
@@ -160,21 +160,6 @@ public abstract class SizeThunk implements Cloneable {
};
}
- public static SizeThunk sub(final SizeThunk thunk1,
- final SizeThunk thunk2) {
- return new SizeThunk() {
- public long computeSize(MachineDescription machDesc) {
- return thunk1.computeSize(machDesc) - thunk2.computeSize(machDesc);
- }
- public long computeAlignment(MachineDescription machDesc) {
- // FIXME
- final long thunk1A = thunk1.computeAlignment(machDesc);
- final long thunk2A = thunk2.computeAlignment(machDesc);
- return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ;
- }
- };
- }
-
public static SizeThunk mul(final SizeThunk thunk1,
final SizeThunk thunk2) {
return new SizeThunk() {
@@ -189,36 +174,26 @@ public abstract class SizeThunk implements Cloneable {
};
}
- public static SizeThunk mod(final SizeThunk thunk1,
- final SizeThunk thunk2) {
- return new SizeThunk() {
- public long computeSize(MachineDescription machDesc) {
- return thunk1.computeSize(machDesc) % thunk2.computeSize(machDesc);
- }
- public long computeAlignment(MachineDescription machDesc) {
- // FIXME
- final long thunk1A = thunk1.computeAlignment(machDesc);
- final long thunk2A = thunk2.computeAlignment(machDesc);
- return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ;
- }
- };
- }
-
- public static SizeThunk roundUp(final SizeThunk thunk1,
- final SizeThunk thunk2) {
+ public static SizeThunk align(final SizeThunk offsetThunk,
+ final SizeThunk alignmentThunk) {
return new SizeThunk() {
public long computeSize(MachineDescription machDesc) {
- final long sz1 = thunk1.computeSize(machDesc);
- final long sz2 = thunk2.computeSize(machDesc);
- final long rem = (sz1 % sz2);
- if (rem == 0) {
- return sz1;
- }
- return sz1 + (sz2 - rem);
+ // x % 2n == x & (2n - 1)
+ // remainder = net_size & ( alignment - 1 )
+ // padding = alignment - remainder ;
+ // aligned_size = net_size + padding ;
+
+ final long size = offsetThunk.computeSize(machDesc);
+ final long alignment = alignmentThunk.computeAlignment(machDesc);
+
+ final long remainder = size & ( alignment - 1 ) ;
+ final long padding = (remainder > 0) ? alignment - remainder : 0;
+ return size + padding;
}
+
public long computeAlignment(MachineDescription machDesc) {
- final long thunk1A = thunk1.computeAlignment(machDesc);
- final long thunk2A = thunk2.computeAlignment(machDesc);
+ final long thunk1A = offsetThunk.computeAlignment(machDesc);
+ final long thunk2A = alignmentThunk.computeAlignment(machDesc);
return ( thunk1A > thunk2A ) ? thunk1A : thunk2A ;
}
};
@@ -244,7 +219,7 @@ public abstract class SizeThunk implements Cloneable {
return constant;
}
public long computeAlignment(MachineDescription machDesc) {
- return 1; // no real alignment for constants
+ return 1; // no alignment for constants
}
};
}
diff --git a/src/java/com/jogamp/gluegen/StructLayout.java b/src/java/com/jogamp/gluegen/runtime/types/StructLayout.java
index 392e1b1..95b7585 100644
--- a/src/java/com/jogamp/gluegen/StructLayout.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/StructLayout.java
@@ -38,10 +38,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen;
-
-import com.jogamp.common.os.Platform;
-import com.jogamp.gluegen.cgram.types.*;
+package com.jogamp.gluegen.runtime.types;
/** Encapsulates algorithm for laying out data structures. Note that
this ends up embedding code in various places via SizeThunks. If
@@ -52,15 +49,19 @@ import com.jogamp.gluegen.cgram.types.*;
public class StructLayout {
private int baseOffset;
- private int structAlignment;
- protected StructLayout(int baseOffset,
- int structAlignment) {
+ protected StructLayout(int baseOffset) {
this.baseOffset = baseOffset;
- this.structAlignment = structAlignment;
}
public void layout(CompoundType t) {
+ /**
+ * - 1) align offset for the new data type,
+ * using the new data type alignment.
+ * Offsets are always upfront.
+ * - 2) add the aligned size of the new data type
+ * - 3) add trailing padding (largest element size)
+ */
int n = t.getNumFields();
SizeThunk curOffset = SizeThunk.constant(baseOffset);
SizeThunk maxSize = SizeThunk.constant(0);
@@ -68,8 +69,8 @@ public class StructLayout {
Field f = t.getField(i);
Type ft = f.getType();
if (ft.isInt() || ft.isFloat() || ft.isDouble() || ft.isPointer()) {
- SizeThunk sz = ft.getSize();
- curOffset = SizeThunk.roundUp(curOffset, sz);
+ final SizeThunk sz = ft.getSize();
+ curOffset = SizeThunk.align(curOffset, sz);
f.setOffset(curOffset);
if (t.isUnion()) {
maxSize = SizeThunk.max(maxSize, sz);
@@ -77,25 +78,34 @@ public class StructLayout {
curOffset = SizeThunk.add(curOffset, sz);
}
} else if (ft.isCompound()) {
- new StructLayout(0, structAlignment).layout(ft.asCompound());
- curOffset = SizeThunk.roundUp(curOffset, SizeThunk.constant(structAlignment));
+ final CompoundType ct = ft.asCompound();
+ if(!ct.isLayouted()) {
+ StructLayout.layout(0, ct);
+ }
+ final SizeThunk sz = ct.getSize();
+ curOffset = SizeThunk.align(curOffset, sz);
f.setOffset(curOffset);
if (t.isUnion()) {
- maxSize = SizeThunk.max(maxSize, ft.getSize());
+ maxSize = SizeThunk.max(maxSize, sz);
} else {
- curOffset = SizeThunk.add(curOffset, ft.getSize());
+ curOffset = SizeThunk.add(curOffset, sz);
}
} else if (ft.isArray()) {
ArrayType arrayType = ft.asArray();
- CompoundType compoundElementType = arrayType.getBaseElementType().asCompound();
- if (compoundElementType != null) {
- new StructLayout(0, structAlignment).layout(compoundElementType);
- arrayType.recomputeSize();
+ if(!arrayType.isLayouted()) {
+ CompoundType compoundElementType = arrayType.getBaseElementType().asCompound();
+ if (compoundElementType != null) {
+ if(!compoundElementType.isLayouted()) {
+ StructLayout.layout(0, compoundElementType);
+ }
+ arrayType.recomputeSize();
+ }
+ arrayType.setLayouted();
}
- // Note: not sure how this rounding is done
- curOffset = SizeThunk.roundUp(curOffset, SizeThunk.constant(structAlignment));
+ final SizeThunk sz = ft.getSize();
+ curOffset = SizeThunk.align(curOffset, sz);
f.setOffset(curOffset);
- curOffset = SizeThunk.add(curOffset, ft.getSize());
+ curOffset = SizeThunk.add(curOffset, sz);
} else {
// FIXME
String name = t.getName();
@@ -108,52 +118,21 @@ public class StructLayout {
") not implemented yet");
}
}
- // FIXME: I think the below is wrong; better check with some examples
- // if ((curOffset % structAlignment) != 0) {
- // curOffset += structAlignment - (curOffset % structAlignment);
- // }
if (t.isUnion()) {
t.setSize(maxSize);
} else {
+ // trailing struct padding ..
+ curOffset = SizeThunk.align(curOffset, curOffset);
t.setSize(curOffset);
}
+ t.setLayouted();
}
-
-
- /**
- * <P>See alignment in {@link com.jogamp.common.os.MachineDescription}.</p>
- *
- * <P>The code is currently used at compile time {@link JavaEmitter#layoutStruct(CompoundType t)} once,
- * and code for structs is emitted for generic 32bit and 64bit only {@link JavaEmitter#emitStruct(CompoundType structType, String alternateName)}.</p>
- */
- public static StructLayout createForCurrentPlatform() {
- final Platform.OSType osType = Platform.getOSType();
- final Platform.CPUArch cpuArch = Platform.getCPUArch();
-
- if( ( Platform.OSType.WINDOWS == osType && Platform.CPUArch.X86_32 == cpuArch ) || // It appears that Windows uses a packing alignment of 4 bytes in 32-bit mode
- ( Platform.CPUArch.ARM_32 == cpuArch )
- ) {
- return new StructLayout(0, 4);
- } else if ((Platform.OSType.WINDOWS == osType && Platform.CPUArch.X86_64 == cpuArch) ||
- (Platform.OSType.LINUX == osType && Platform.CPUArch.X86_32 == cpuArch) ||
- (Platform.OSType.LINUX == osType && Platform.CPUArch.X86_64 == cpuArch) ||
- (Platform.OSType.LINUX == osType && Platform.CPUArch.IA64 == cpuArch) ||
- (Platform.OSType.SUNOS == osType && Platform.CPUArch.SPARC_32 == cpuArch) ||
- (Platform.OSType.SUNOS == osType && Platform.CPUArch.SPARCV9_64 == cpuArch) ||
- (Platform.OSType.SUNOS == osType && Platform.CPUArch.X86_32 == cpuArch) ||
- (Platform.OSType.SUNOS == osType && Platform.CPUArch.X86_64 == cpuArch) ||
- (Platform.OSType.MACOS == osType && Platform.CPUArch.PPC == cpuArch) ||
- (Platform.OSType.MACOS == osType && Platform.CPUArch.X86_32 == cpuArch) ||
- (Platform.OSType.MACOS == osType && Platform.CPUArch.X86_64 == cpuArch) ||
- (Platform.OSType.FREEBSD == osType && Platform.CPUArch.X86_32 == cpuArch) ||
- (Platform.OSType.FREEBSD == osType && Platform.CPUArch.X86_64 == cpuArch) ||
- (Platform.OSType.HPUX == osType && Platform.CPUArch.PA_RISC2_0 == cpuArch)
- ) {
- return new StructLayout(0, 8);
- } else {
- // FIXME: add more ports
- throw new RuntimeException("Please port StructLayout to your OS (" + osType + ") and CPU (" + cpuArch + ")");
- }
+ public static StructLayout create(int baseOffset) {
+ return new StructLayout(baseOffset);
}
+
+ public static void layout(int baseOffset, CompoundType t) {
+ create(baseOffset).layout(t);
+ }
}
diff --git a/src/java/com/jogamp/gluegen/runtime/types/StructType.java b/src/java/com/jogamp/gluegen/runtime/types/StructType.java
new file mode 100644
index 0000000..2c0a589
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/types/StructType.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.gluegen.runtime.types;
+
+public class StructType extends CompoundType {
+
+ public StructType(String name, SizeThunk size, int cvAttributes) {
+ this(name, size, cvAttributes, null);
+ }
+
+ StructType(String name, SizeThunk size, int cvAttributes, String structName) {
+ super (name, size, cvAttributes, structName);
+ }
+
+ @Override
+ public boolean equals(Object arg) {
+ if (arg == null || !(arg instanceof StructType)) {
+ return false;
+ }
+ return super.equals(arg);
+ }
+
+ public final boolean isStruct() { return true; }
+ public final boolean isUnion() { return false; }
+
+ Type newCVVariant(int cvAttributes) {
+ StructType t = new StructType(getName(), getSize(), cvAttributes, getStructName());
+ t.setFields(getFields());
+ return t;
+ }
+
+}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/Type.java b/src/java/com/jogamp/gluegen/runtime/types/Type.java
index 27aff92..ebedfcb 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/Type.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/Type.java
@@ -38,7 +38,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
import java.util.List;
@@ -269,5 +269,5 @@ public abstract class Type implements Cloneable {
/** Helper routine for list equality comparison */
static boolean listsEqual(List a, List b) {
return ((a == null && b == null) || (a != null && b != null && a.equals(b)));
- }
+ }
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/TypeVisitor.java b/src/java/com/jogamp/gluegen/runtime/types/TypeVisitor.java
index 0889681..0d7f63d 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/TypeVisitor.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/TypeVisitor.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
public interface TypeVisitor {
public void visitType(Type t);
diff --git a/src/java/com/jogamp/gluegen/runtime/types/UnionType.java b/src/java/com/jogamp/gluegen/runtime/types/UnionType.java
new file mode 100644
index 0000000..5aee3f1
--- /dev/null
+++ b/src/java/com/jogamp/gluegen/runtime/types/UnionType.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.gluegen.runtime.types;
+
+public class UnionType extends CompoundType {
+
+ public UnionType(String name, SizeThunk size, int cvAttributes) {
+ this(name, size, cvAttributes, null);
+ }
+
+ UnionType(String name, SizeThunk size, int cvAttributes, String structName) {
+ super (name, size, cvAttributes, structName);
+ }
+
+ @Override
+ public boolean equals(Object arg) {
+ if (arg == null || !(arg instanceof UnionType)) {
+ return false;
+ }
+ return super.equals(arg);
+ }
+
+ public final boolean isStruct() { return false; }
+ public final boolean isUnion() { return true; }
+
+ Type newCVVariant(int cvAttributes) {
+ UnionType t = new UnionType(getName(), getSize(), cvAttributes, getStructName());
+ t.setFields(getFields());
+ return t;
+ }
+
+}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/VoidType.java b/src/java/com/jogamp/gluegen/runtime/types/VoidType.java
index fa098e7..07b3ec3 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/VoidType.java
+++ b/src/java/com/jogamp/gluegen/runtime/types/VoidType.java
@@ -37,7 +37,7 @@
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.jogamp.gluegen.cgram.types;
+package com.jogamp.gluegen.runtime.types;
public class VoidType extends Type implements Cloneable {