aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/antlr/com/jogamp/gluegen/cgram/HeaderParser.g130
-rw-r--r--src/java/com/jogamp/gluegen/CMethodBindingEmitter.java70
-rw-r--r--src/java/com/jogamp/gluegen/GlueGen.java6
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java118
-rw-r--r--src/java/com/jogamp/gluegen/ReferencedStructs.java2
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/ArrayType.java17
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/BitType.java13
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/CompoundType.java17
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/DoubleType.java12
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/EnumType.java19
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/FloatType.java12
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/FunctionType.java11
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/MemoryLayoutType.java6
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/PointerType.java26
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java6
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/StructType.java16
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/Type.java126
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/UnionType.java16
-rw-r--r--src/java/com/jogamp/gluegen/cgram/types/VoidType.java16
-rw-r--r--src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java2
-rw-r--r--src/java/com/jogamp/gluegen/structgen/CStructAnnotationProcessor.java9
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/generation/test1.h2
-rw-r--r--src/junit/com/jogamp/gluegen/test/junit/internals/TestType.java8
23 files changed, 411 insertions, 249 deletions
diff --git a/src/antlr/com/jogamp/gluegen/cgram/HeaderParser.g b/src/antlr/com/jogamp/gluegen/cgram/HeaderParser.g
index 18947f6..595d770 100644
--- a/src/antlr/com/jogamp/gluegen/cgram/HeaderParser.g
+++ b/src/antlr/com/jogamp/gluegen/cgram/HeaderParser.g
@@ -136,10 +136,11 @@ options {
private CompoundType lookupInStructDictionary(String structName,
CompoundTypeKind kind,
- int cvAttrs) {
+ int cvAttrs, final ASTLocusTag locusTag)
+ {
CompoundType t = (CompoundType) structDictionary.get(structName);
if (t == null) {
- t = CompoundType.create(structName, null, kind, cvAttrs);
+ t = CompoundType.create(structName, null, kind, cvAttrs, locusTag);
structDictionary.put(structName, t);
}
return t;
@@ -300,24 +301,27 @@ options {
private boolean isFuncDeclaration; // Used to only process function typedefs
private String funcDeclName;
private List<ParameterDeclaration> funcDeclParams;
+ private ASTLocusTag funcLocusTag;
private void resetFuncDeclaration() {
isFuncDeclaration = false;
funcDeclName = null;
funcDeclParams = null;
+ funcLocusTag = null;
}
- private void setFuncDeclaration(final String name, final List<ParameterDeclaration> p) {
+ private void setFuncDeclaration(final String name, final List<ParameterDeclaration> p, final ASTLocusTag locusTag) {
isFuncDeclaration = true;
funcDeclName = name;
funcDeclParams = p;
+ funcLocusTag = locusTag;
}
- private void processDeclaration(Type returnType, ASTLocusTag locusTag) {
+ private void processDeclaration(Type returnType) {
if (isFuncDeclaration) {
final FunctionSymbol sym = new FunctionSymbol(funcDeclName,
- new FunctionType(null, null, resolveAnonCompound(returnType), 0),
- locusTag);
- debugPrintln("Function ... "+sym.toString()+" @ "+locusTag);
+ new FunctionType(null, null, resolveAnonCompound(returnType), 0, funcLocusTag),
+ funcLocusTag);
+ debugPrintln("Function ... "+sym.toString()+" @ "+funcLocusTag);
if (funcDeclParams != null) { // handle funcs w/ empty parameter lists (e.g., "foo()")
for (Iterator<ParameterDeclaration> iter = funcDeclParams.iterator(); iter.hasNext(); ) {
ParameterDeclaration pd = iter.next();
@@ -326,7 +330,7 @@ options {
sym.addArgument(pd.type(), pd.id());
}
}
- debugPrintln("Function Added "+sym.toString()+" @ "+locusTag);
+ debugPrintln("Function Added "+sym.toString());
functions.add(sym);
resetFuncDeclaration();
}
@@ -345,18 +349,18 @@ options {
/** Helper routine which handles creating a pointer or array type
for [] expressions */
- private void handleArrayExpr(TypeBox tb, AST t) {
+ private void handleArrayExpr(TypeBox tb, AST t, ASTLocusTag locusTag) {
if (t != null) {
try {
final int len = parseIntConstExpr(t);
- tb.setType(canonicalize(new ArrayType(tb.type(), SizeThunk.mul(SizeThunk.constant(len), tb.type().getSize()), len, 0)));
+ tb.setType(canonicalize(new ArrayType(tb.type(), SizeThunk.mul(SizeThunk.constant(len), tb.type().getSize()), len, 0, locusTag)));
return;
} catch (RecognitionException e) {
// Fall through
}
}
tb.setType(canonicalize(new PointerType(SizeThunk.POINTER,
- tb.type(), 0, null)));
+ tb.type(), 0, locusTag)));
}
private int parseIntConstExpr(AST t) throws RecognitionException {
@@ -365,7 +369,7 @@ options {
/** Utility function: creates a new EnumType with the given name, or
returns an existing one if it has already been created. */
- private EnumType getEnumType(String enumTypeName, ASTLocusTag locus) {
+ private EnumType getEnumType(String enumTypeName, ASTLocusTag locusTag) {
EnumType enumType = null;
Iterator<EnumType> it = enumHash.values().iterator();
while (it.hasNext()) {
@@ -382,7 +386,7 @@ options {
// entry the enum should expand to e.g. int64. However, using
// "long" here (which is what used to be the case) was
// definitely incorrect and caused problems.
- enumType = new EnumType(enumTypeName, SizeThunk.INT32, locus);
+ enumType = new EnumType(enumTypeName, SizeThunk.INT32, locusTag);
}
return enumType;
@@ -458,6 +462,7 @@ declarator[TypeBox tb] returns [String s] {
List<ParameterDeclaration> params = null;
String funcPointerName = null;
TypeBox dummyTypeBox = null;
+ final ASTLocusTag locusTag = findASTLocusTag(declarator_AST_in);
}
: #( NDeclarator
( pointerGroup[tb] )?
@@ -474,17 +479,17 @@ declarator[TypeBox tb] returns [String s] {
RPAREN
) {
if (id != null) {
- setFuncDeclaration(id.getText(), params);
+ setFuncDeclaration(id.getText(), params, locusTag);
} else if ( funcPointerName != null ) {
/* TypeBox becomes function pointer in this case */
- FunctionType ft = new FunctionType(null, null, tb.type(), 0);
+ final FunctionType ft = new FunctionType(null, null, tb.type(), 0, locusTag);
if (params == null) {
// If the function pointer has no declared parameters, it's a
// void function. I'm not sure if the parameter name is
// ever referenced anywhere when the type is VoidType, so
// just in case I'll set it to a comment string so it will
// still compile if written out to code anywhere.
- ft.addArgument(new VoidType(0), "/*unnamed-void*/");
+ ft.addArgument(new VoidType(0, locusTag), "/*unnamed-void*/");
} else {
for (Iterator iter = params.iterator(); iter.hasNext(); ) {
ParameterDeclaration pd = (ParameterDeclaration) iter.next();
@@ -492,11 +497,11 @@ declarator[TypeBox tb] returns [String s] {
}
}
tb.setType(canonicalize(new PointerType(SizeThunk.POINTER,
- ft, 0, null)));
+ ft, 0, locusTag)));
s = funcPointerName;
}
}
- | LBRACKET ( e:expr )? RBRACKET { handleArrayExpr(tb, e); }
+ | LBRACKET ( e:expr )? RBRACKET { handleArrayExpr(tb, e, locusTag); }
)*
)
;
@@ -516,7 +521,7 @@ declaration {
initDeclList[tb]
)?
( SEMI )+
- ) { processDeclaration(tb.type(), findASTLocusTag(declaration_AST_in)); }
+ ) { processDeclaration(tb.type()); }
;
parameterTypeList returns [List<ParameterDeclaration> l] { l = new ArrayList<ParameterDeclaration>(); ParameterDeclaration decl = null; }
@@ -559,7 +564,10 @@ declSpecifiers returns [TypeBox tb] {
{
if (t == null &&
(x & (SIGNED | UNSIGNED)) != 0) {
- t = new IntType("int", SizeThunk.INTxx, ((x & UNSIGNED) != 0), attrs2CVAttrs(x));
+ t = new IntType("int", SizeThunk.INTxx,
+ ((x & UNSIGNED) != 0),
+ attrs2CVAttrs(x),
+ findASTLocusTag(declSpecifiers_AST_in));
}
tb = new TypeBox(t, ((x & TYPEDEF) != 0));
}
@@ -590,30 +598,35 @@ typeQualifier returns [int x] { x = 0; }
typeSpecifier[int attributes] returns [Type t] {
t = null;
int cvAttrs = attrs2CVAttrs(attributes);
- boolean unsigned = ((attributes & UNSIGNED) != 0);
+ boolean unsig = ((attributes & UNSIGNED) != 0);
+ final ASTLocusTag locusTag = findASTLocusTag(typeSpecifier_AST_in);
}
- : "void" { t = new VoidType(cvAttrs); }
- | "char" { t = new IntType("char" , SizeThunk.INT8, unsigned, cvAttrs); }
- | "short" { t = new IntType("short", SizeThunk.INT16, unsigned, cvAttrs); }
- | "int" { t = new IntType("int" , SizeThunk.INTxx, unsigned, cvAttrs); }
- | "long" { t = new IntType("long" , SizeThunk.LONG, unsigned, cvAttrs); }
- | "float" { t = new FloatType("float", SizeThunk.FLOAT, cvAttrs); }
- | "double" { t = new DoubleType("double", SizeThunk.DOUBLE, cvAttrs); }
- | "__int32" { t = new IntType("__int32", SizeThunk.INT32, unsigned, cvAttrs); }
- | "__int64" { t = new IntType("__int64", SizeThunk.INT64, unsigned, cvAttrs); }
- | "int8_t" { t = new IntType("int8_t", SizeThunk.INT8, false, cvAttrs); /* TS: always signed */ }
- | "uint8_t" { t = new IntType("uint8_t", SizeThunk.INT8, true, cvAttrs); /* TS: always unsigned */ }
- | "int16_t" { t = new IntType("int16_t", SizeThunk.INT16, false, cvAttrs); /* TS: always signed */ }
- | "uint16_t" { t = new IntType("uint16_t", SizeThunk.INT16, true, cvAttrs); /* TS: always unsigned */ }
- | "int32_t" { t = new IntType("int32_t", SizeThunk.INT32, false, cvAttrs); /* TS: always signed */ }
- | "wchar_t" { t = new IntType("wchar_t", SizeThunk.INT32, false, cvAttrs); /* TS: always signed */ }
- | "uint32_t" { t = new IntType("uint32_t", SizeThunk.INT32, true, cvAttrs, true); /* TS: always unsigned */ }
- | "int64_t" { t = new IntType("int64_t", SizeThunk.INT64, false, cvAttrs); /* TS: always signed */ }
- | "uint64_t" { t = new IntType("uint64_t", SizeThunk.INT64, true, cvAttrs, true); /* TS: always unsigned */ }
- | "ptrdiff_t" { t = new IntType("ptrdiff_t", SizeThunk.POINTER, false, cvAttrs); /* TS: always signed */ }
- | "intptr_t" { t = new IntType("intptr_t", SizeThunk.POINTER, false, cvAttrs); /* TS: always signed */ }
- | "size_t" { t = new IntType("size_t", SizeThunk.POINTER, true, cvAttrs, true); /* TS: always unsigned */ }
- | "uintptr_t" { t = new IntType("uintptr_t", SizeThunk.POINTER, true, cvAttrs, true); /* TS: always unsigned */ }
+ //
+ // TYPEDEF
+ // UNSIGNED |
+ // TOKEN TYPE NAME SIZE | ATTRIBS | LOCUS
+ : "void" { t = new VoidType( cvAttrs, locusTag); }
+ | "char" { t = new IntType("char" , SizeThunk.INT8, unsig, cvAttrs, false, locusTag); }
+ | "short" { t = new IntType("short", SizeThunk.INT16, unsig, cvAttrs, false, locusTag); }
+ | "int" { t = new IntType("int" , SizeThunk.INTxx, unsig, cvAttrs, false, locusTag); }
+ | "long" { t = new IntType("long" , SizeThunk.LONG, unsig, cvAttrs, false, locusTag); }
+ | "float" { t = new FloatType("float", SizeThunk.FLOAT, cvAttrs, locusTag); }
+ | "double" { t = new DoubleType("double", SizeThunk.DOUBLE, cvAttrs, locusTag); }
+ | "__int32" { t = new IntType("__int32", SizeThunk.INT32, unsig, cvAttrs, false, locusTag); }
+ | "__int64" { t = new IntType("__int64", SizeThunk.INT64, unsig, cvAttrs, false, locusTag); }
+ | "int8_t" { t = new IntType("int8_t", SizeThunk.INT8, false, cvAttrs, true, locusTag); } /* TS: always signed */
+ | "uint8_t" { t = new IntType("uint8_t", SizeThunk.INT8, true, cvAttrs, true, locusTag); } /* TS: always unsigned */
+ | "int16_t" { t = new IntType("int16_t", SizeThunk.INT16, false, cvAttrs, true, locusTag); } /* TS: always signed */
+ | "uint16_t" { t = new IntType("uint16_t", SizeThunk.INT16, true, cvAttrs, true, locusTag); } /* TS: always unsigned */
+ | "int32_t" { t = new IntType("int32_t", SizeThunk.INT32, false, cvAttrs, true, locusTag); } /* TS: always signed */
+ | "wchar_t" { t = new IntType("wchar_t", SizeThunk.INT32, false, cvAttrs, true, locusTag); } /* TS: always signed */
+ | "uint32_t" { t = new IntType("uint32_t", SizeThunk.INT32, true, cvAttrs, true, locusTag); } /* TS: always unsigned */
+ | "int64_t" { t = new IntType("int64_t", SizeThunk.INT64, false, cvAttrs, true, locusTag); } /* TS: always signed */
+ | "uint64_t" { t = new IntType("uint64_t", SizeThunk.INT64, true, cvAttrs, true, locusTag); } /* TS: always unsigned */
+ | "ptrdiff_t" { t = new IntType("ptrdiff_t", SizeThunk.POINTER, false, cvAttrs, true, locusTag); } /* TS: always signed */
+ | "intptr_t" { t = new IntType("intptr_t", SizeThunk.POINTER, false, cvAttrs, true, locusTag); } /* TS: always signed */
+ | "size_t" { t = new IntType("size_t", SizeThunk.POINTER, true, cvAttrs, true, locusTag); } /* TS: always unsigned */
+ | "uintptr_t" { t = new IntType("uintptr_t", SizeThunk.POINTER, true, cvAttrs, true, locusTag); } /* TS: always unsigned */
| t = structSpecifier[cvAttrs] ( attributeDecl )*
| t = unionSpecifier [cvAttrs] ( attributeDecl )*
| t = enumSpecifier [cvAttrs]
@@ -650,20 +663,21 @@ unionSpecifier[int cvAttrs] returns [Type t] { t = null; }
structOrUnionBody[CompoundTypeKind kind, int cvAttrs] returns [CompoundType t] {
t = null;
boolean addedAny = false;
+ final ASTLocusTag locusTag = findASTLocusTag(structOrUnionBody_AST_in);
}
: ( (ID LCURLY) => id:ID LCURLY {
// fully declared struct, i.e. not anonymous
- t = (CompoundType) canonicalize(lookupInStructDictionary(id.getText(), kind, cvAttrs));
+ t = (CompoundType) canonicalize(lookupInStructDictionary(id.getText(), kind, cvAttrs, locusTag));
} ( addedAny = structDeclarationList[t] )?
RCURLY { t.setBodyParsed(addedAny); }
| LCURLY {
// anonymous declared struct
- t = CompoundType.create(null, null, kind, cvAttrs);
+ t = CompoundType.create(null, null, kind, cvAttrs, locusTag);
} ( structDeclarationList[t] )?
RCURLY { t.setBodyParsed(false); }
| id2:ID {
// anonymous struct
- t = (CompoundType) canonicalize(lookupInStructDictionary(id2.getText(), kind, cvAttrs));
+ t = (CompoundType) canonicalize(lookupInStructDictionary(id2.getText(), kind, cvAttrs, locusTag));
}
)
;
@@ -701,7 +715,8 @@ specifierQualifierList returns [Type t] {
)+ {
if (t == null &&
(x & (SIGNED | UNSIGNED)) != 0) {
- t = new IntType("int", SizeThunk.INTxx, ((x & UNSIGNED) != 0), attrs2CVAttrs(x));
+ t = new IntType("int", SizeThunk.INTxx, ((x & UNSIGNED) != 0), attrs2CVAttrs(x),
+ findASTLocusTag(specifierQualifierList_AST_in));
}
}
;
@@ -740,12 +755,12 @@ structDeclarator[CompoundType containingType, Type t] returns [boolean addedAny]
enumSpecifier [int cvAttrs] returns [Type t] {
t = null;
EnumType e = null;
- ASTLocusTag locus = findASTLocusTag(enumSpecifier_AST_in);
+ ASTLocusTag locusTag = findASTLocusTag(enumSpecifier_AST_in);
}
: #( "enum"
- ( ( ID LCURLY )=> i:ID LCURLY enumList[(EnumType)(e = getEnumType(i.getText(), locus))] RCURLY
- | LCURLY enumList[(EnumType)(e = getEnumType(ANONYMOUS_ENUM_NAME, locus))] RCURLY
- | ID { e = getEnumType(i.getText(), locus); }
+ ( ( ID LCURLY )=> i:ID LCURLY enumList[(EnumType)(e = getEnumType(i.getText(), locusTag))] RCURLY
+ | LCURLY enumList[(EnumType)(e = getEnumType(ANONYMOUS_ENUM_NAME, locusTag))] RCURLY
+ | ID { e = getEnumType(i.getText(), locusTag); }
) {
debugPrintln("Adding enum mapping: "+getDebugTypeString(e));
if( null != e ) {
@@ -834,7 +849,7 @@ initDecl[TypeBox tb] {
if ((declName != null) && (tb != null) && tb.isTypedef()) {
Type t = tb.type();
debugPrint("Adding typedef mapping: [" + declName + "] -> "+getDebugTypeString(t));
- if (!t.hasTypedefName()) {
+ if (!t.isTypedef()) {
if( t.isCompound() ) {
// Allow redefinition of newly defined struct, i.e. use same instance.
// This aliases '_a' -> 'A' for 'typedef struct _a { } A, *B;', where '*B' will become also '*A'.
@@ -890,7 +905,8 @@ pointerGroup[TypeBox tb] { int x = 0; int y = 0; }
if (tb != null) {
tb.setType(canonicalize(new PointerType(SizeThunk.POINTER,
tb.type(),
- attrs2CVAttrs(x), null)));
+ attrs2CVAttrs(x),
+ findASTLocusTag(pointerGroup_AST_in))));
}
}
)+ )
@@ -915,7 +931,9 @@ typeName {
/* FIXME: the handling of types in this rule has not been well thought
out and is known to be incomplete. Currently it is only used to handle
pointerGroups for unnamed parameters. */
-nonemptyAbstractDeclarator[TypeBox tb]
+nonemptyAbstractDeclarator[TypeBox tb] {
+ final ASTLocusTag locusTag = findASTLocusTag(nonemptyAbstractDeclarator_AST_in);
+}
: #( NNonemptyAbstractDeclarator
( pointerGroup[tb]
( (LPAREN
@@ -923,7 +941,7 @@ nonemptyAbstractDeclarator[TypeBox tb]
| parameterTypeList
)?
RPAREN)
- | (LBRACKET (e1:expr)? RBRACKET) { handleArrayExpr(tb, e1); }
+ | (LBRACKET (e1:expr)? RBRACKET) { handleArrayExpr(tb, e1, locusTag); }
)*
| ( (LPAREN
@@ -931,7 +949,7 @@ nonemptyAbstractDeclarator[TypeBox tb]
| parameterTypeList
)?
RPAREN)
- | (LBRACKET (e2:expr)? RBRACKET) { handleArrayExpr(tb, e2); }
+ | (LBRACKET (e2:expr)? RBRACKET) { handleArrayExpr(tb, e2, locusTag); }
)+
)
)
diff --git a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
index 47b2811..85c6d7e 100644
--- a/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/CMethodBindingEmitter.java
@@ -607,9 +607,9 @@ public class CMethodBindingEmitter extends FunctionEmitter {
// FIXME: if the arg type is non-const, the sematics might be that
// the function modifies the argument -- we don't yet support
// this.
- throw new RuntimeException(
- "Cannot copy data for ptr-to-ptr arg type \"" + cArgType +
- "\": support for non-const ptr-to-ptr types not implemented.");
+ throw new GlueGenException(
+ "Cannot copy data for ptr-to-ptr arg type \"" + cArgType.getDebugString() +
+ "\": support for non-const ptr-to-ptr types not implemented: "+binding, binding.getCSymbol().getASTLocusTag());
}
writer.println();
@@ -653,9 +653,10 @@ public class CMethodBindingEmitter extends FunctionEmitter {
error = 100;
}
if( 0 < error ) {
- throw new RuntimeException(
- "Could not copy data for type \"" + cArgType +
- "\"; currently only pointer- and array-types are supported. (error "+error+")");
+ throw new GlueGenException(
+ "Could not copy data for type \"" + cArgType.getDebugString() +
+ "\"; currently only pointer- and array-types are supported. (error "+error+"): "+binding,
+ binding.getCSymbol().getASTLocusTag());
}
}
emitMalloc(
@@ -715,7 +716,8 @@ public class CMethodBindingEmitter extends FunctionEmitter {
null, true);
} else {
if( null == cArgElementType2 ) {
- throw new RuntimeException("XXX: Type "+cArgType+" not properly handled as ptr-to-ptr");
+ throw new GlueGenException("XXX: Type "+cArgType.getDebugString()+" not properly handled as ptr-to-ptr: "+binding,
+ binding.getCSymbol().getASTLocusTag());
}
// Question: do we always need to copy the sub-arrays, or just
// GetPrimitiveArrayCritical on each jobjectarray element and
@@ -732,8 +734,9 @@ public class CMethodBindingEmitter extends FunctionEmitter {
"Could not allocate buffer during copying of data in argument \\\""+javaArgName+"\\\"");
// FIXME: copy the data (use matched Get/ReleasePrimitiveArrayCritical() calls)
if (true) {
- throw new RuntimeException("Cannot yet handle type \"" + cArgType.getCName() +
- "\"; need to add support for copying ptr-to-ptr-to-primitiveType subarrays");
+ throw new GlueGenException("Cannot yet handle type \"" + cArgType.getDebugString() +
+ "\"; need to add support for copying ptr-to-ptr-to-primitiveType subarrays: "+binding,
+ binding.getCSymbol().getASTLocusTag());
}
}
@@ -817,9 +820,10 @@ public class CMethodBindingEmitter extends FunctionEmitter {
null);
writer.println(" }");
} else {
- throw new RuntimeException(
- "Cannot clean up copied data for ptr-to-ptr arg type \"" + cArgType +
- "\": support for cleaning up most non-const ptr-to-ptr types not implemented.");
+ throw new GlueGenException(
+ "Cannot clean up copied data for ptr-to-ptr arg type \"" + cArgType.getDebugString() +
+ "\": support for cleaning up most non-const ptr-to-ptr types not implemented.",
+ binding.getCSymbol().getASTLocusTag());
}
}
@@ -840,9 +844,10 @@ public class CMethodBindingEmitter extends FunctionEmitter {
// free each element
final PointerType cArgPtrType = cArgType.asPointer();
if (cArgPtrType == null) {
- throw new RuntimeException(
- "Could not copy data for type \"" + cArgType +
- "\"; currently only pointer types supported.");
+ throw new GlueGenException(
+ "Could not copy data for type \"" + cArgType.getDebugString() +
+ "\"; currently only pointer types supported.",
+ binding.getCSymbol().getASTLocusTag());
}
// process each element in the array
@@ -861,9 +866,10 @@ public class CMethodBindingEmitter extends FunctionEmitter {
writer.print(convName+"_copy[_copyIndex]");
writer.println(");");
} else {
- if (true) throw new RuntimeException(
- "Cannot yet handle type \"" + cArgType.getCName() +
- "\"; need to add support for cleaning up copied ptr-to-ptr-to-primitiveType subarrays");
+ if (true) throw new GlueGenException(
+ "Cannot yet handle type \"" + cArgType.getDebugString() +
+ "\"; need to add support for cleaning up copied ptr-to-ptr-to-primitiveType subarrays",
+ binding.getCSymbol().getASTLocusTag());
}
writer.println(" }");
}
@@ -1047,12 +1053,13 @@ public class CMethodBindingEmitter extends FunctionEmitter {
{
// fully declared non-anonymous struct pointer: pass content
if ( cReturnTargetType.getSize() == null ) {
- throw new RuntimeException(
+ throw new GlueGenException(
"Error emitting code for compound return type "+
"for function \"" + binding + "\": " +
"Structs to be emitted should have been laid out by this point " +
"(type " + cReturnTargetType.getCName() + " / " +
- cReturnTargetType.getDebugString() + " was not) for "+binding
+ cReturnTargetType.getDebugString() + " was not) for "+binding,
+ binding.getCSymbol().getASTLocusTag()
);
}
writer.println("sizeof(" + cReturnTargetType.getCName() + ") );");
@@ -1103,8 +1110,8 @@ public class CMethodBindingEmitter extends FunctionEmitter {
(javaReturnType.isArray() && javaReturnType.isNIOByteBufferArray())) {
writer.println(" if (NULL == _res) return NULL;");
if (returnValueLengthExpression == null) {
- throw new RuntimeException("Error while generating C code: no length specified for array returned from function " +
- binding);
+ throw new GlueGenException("Error while generating C code: no length specified for array returned from function " +
+ binding, binding.getCSymbol().getASTLocusTag());
}
writer.println(" " + arrayResLength + " = " + returnValueLengthExpression.format(argumentNameArray()) + ";");
writer.println(" " + arrayRes + " = (*env)->NewObjectArray(env, " + arrayResLength + ", (*env)->FindClass(env, \"java/nio/ByteBuffer\"), NULL);");
@@ -1126,9 +1133,10 @@ public class CMethodBindingEmitter extends FunctionEmitter {
// expression which computes the array size (already present
// as ReturnValueCapacity, not yet implemented / tested here)
- throw new RuntimeException(
+ throw new GlueGenException(
"Could not emit native code for function \"" + binding +
- "\": array return values for non-char types not implemented yet, for "+binding);
+ "\": array return values for non-char types not implemented yet, for "+binding,
+ binding.getCSymbol().getASTLocusTag());
// FIXME: This is approximately what will be required here
//
@@ -1150,8 +1158,8 @@ public class CMethodBindingEmitter extends FunctionEmitter {
//writer.print(arrayRes);
//writer.println(";");
} else {
- System.err.print("Unhandled return type: "+javaReturnType.getDebugString());
- throw new RuntimeException("Unhandled return type: "+javaReturnType.getDebugString()+" for "+binding);
+ throw new GlueGenException("Unhandled return type: "+javaReturnType.getDebugString()+" for "+binding,
+ binding.getCSymbol().getReturnType().getASTLocusTag());
}
}
}
@@ -1178,7 +1186,8 @@ public class CMethodBindingEmitter extends FunctionEmitter {
// We should only see "void" as the first argument of a 1-argument function
// FIXME: should normalize this in the parser
if ((i != 0) || (binding.getNumArguments() > 1)) {
- throw new RuntimeException("Saw illegal \"void\" argument while emitting \"" + getName() + "\"");
+ throw new GlueGenException("Saw illegal \"void\" argument while emitting arg "+i+" of "+binding,
+ binding.getCArgumentType(i).getASTLocusTag());
}
} else {
Class<?> c = type.getJavaClass();
@@ -1210,7 +1219,8 @@ public class CMethodBindingEmitter extends FunctionEmitter {
// These are not exposed at the Java level
} else {
// FIXME: add support for char* -> String conversion
- throw new RuntimeException("Unknown kind of JavaType: name="+type.getName());
+ throw new GlueGenException("Unknown kind of JavaType: arg "+i+", name="+type.getName()+" of "+binding,
+ binding.getCArgumentType(i).getASTLocusTag());
}
}
}
@@ -1450,12 +1460,12 @@ public class CMethodBindingEmitter extends FunctionEmitter {
} else {
// type is pointer to pointer of some type we don't support (maybe
// it's an array of pointers to structs?)
- throw new RuntimeException("Unsupported pointer type: \"" + cType.getCName() + "\"");
+ throw new GlueGenException("Unsupported pointer type: \"" + cType.getDebugString() + "\"", cType.getASTLocusTag());
}
} else {
// type is pointer to pointer of some type we don't support (maybe
// it's an array of pointers to structs?)
- throw new RuntimeException("Unsupported pointer type: \"" + cType.getCName() + "\"");
+ throw new GlueGenException("Unsupported pointer type: \"" + cType.getDebugString() + "\"", cType.getASTLocusTag());
}
}
} else {
diff --git a/src/java/com/jogamp/gluegen/GlueGen.java b/src/java/com/jogamp/gluegen/GlueGen.java
index 2833154..4ef5648 100644
--- a/src/java/com/jogamp/gluegen/GlueGen.java
+++ b/src/java/com/jogamp/gluegen/GlueGen.java
@@ -73,6 +73,8 @@ public class GlueGen implements GlueEmitterControls {
private static Level logLevel = null;
+ public static void setDebug(final boolean v) { debug=v; }
+ public static void setLogLevel(final Level l) { logLevel=l; }
public static boolean debug() { return debug; }
@Override
@@ -330,12 +332,12 @@ public class GlueGen implements GlueEmitterControls {
for (final Iterator<Type> iter = referencedStructs.results(); iter.hasNext();) {
final Type t = iter.next();
if (t.isCompound()) {
- assert t.hasTypedefName() && t.getName() == null : "ReferencedStructs incorrectly recorded compound type " + t;
+ assert t.isTypedef() && t.getName() == null : "ReferencedStructs incorrectly recorded compound type " + t;
emit.emitStruct(t.asCompound(), null);
} else if (t.isPointer()) {
final PointerType p = t.asPointer();
final CompoundType c = p.getTargetType().asCompound();
- assert p.hasTypedefName() && c.getName() == null : "ReferencedStructs incorrectly recorded pointer type " + p;
+ assert p.isTypedef() && c.getName() == null : "ReferencedStructs incorrectly recorded pointer type " + p;
emit.emitStruct(c, p);
}
}
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index 7ffa88d..c291022 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -820,7 +820,7 @@ public class JavaEmitter implements GlueEmitter {
}
} // end iteration over expanded bindings
} catch (final Exception e) {
- throw new RuntimeException("Error while generating bindings for \"" + sym + "\"", e);
+ throw new GlueGenException("Error while generating bindings for \"" + sym + "\"", sym.getASTLocusTag(), e);
}
return allEmitters;
@@ -899,7 +899,12 @@ public class JavaEmitter implements GlueEmitter {
return;
}
- final Type containingCType = canonicalize(new PointerType(SizeThunk.POINTER, structCType, 0, typedefedName));
+ final Type containingCType;
+ {
+ final Type aptr = new PointerType(SizeThunk.POINTER, structCType, 0);
+ aptr.setTypedefName(typedefedName);
+ containingCType = canonicalize(aptr);
+ }
final JavaType containingJType = typeToJavaType(containingCType, null);
if( containingJType.isOpaqued() ) {
LOG.log(INFO, "skipping emission of opaque {0}, {1}", containingJType.getDebugString(), structCType.getDebugString());
@@ -913,11 +918,11 @@ public class JavaEmitter implements GlueEmitter {
LOG.log(INFO, "perform emission of \"{0}\" -> \"{1}\": {2}", structCTypeName, containingJTypeName, structCType.getDebugString());
if( GlueGen.debug() ) {
if( null != typedefed ) {
- LOG.log(INFO, " typedefed {0}", typedefed.getDebugString());
+ LOG.log(INFO, " typedefed {0}", typedefed.getDebugString(true));
} else {
LOG.log(INFO, " typedefed {0}", (Object)null);
}
- LOG.log(INFO, " containingCType {0}", containingCType.getDebugString());
+ LOG.log(INFO, " containingCType {0}", containingCType.getDebugString(true));
LOG.log(INFO, " containingJType {0}", containingJType.getDebugString());
}
if( 0 == structCType.getNumFields() ) {
@@ -1061,8 +1066,8 @@ public class JavaEmitter implements GlueEmitter {
// handle the union in jawt_Win32DrawingSurfaceInfo (fabricate
// a name?)
if (fieldType.getName() == null) {
- throw new RuntimeException("Anonymous structs as fields not supported yet, field \"" +
- cfgFieldName1 + "\", "+fieldType.getDebugString());
+ throw new GlueGenException("Anonymous structs as fields not supported yet, field \"" +
+ cfgFieldName1 + "\", "+fieldType.getDebugString(), fieldType.getASTLocusTag());
}
if( GlueGen.debug() ) {
System.err.printf("SE.os.%02d: %s / %s, %s (%s)%n", (i+1), field, cfgFieldName1, fieldType.getDebugString(), "compound");
@@ -1080,11 +1085,11 @@ public class JavaEmitter implements GlueEmitter {
try {
externalJavaType = typeToJavaType(fieldType, machDescJava);
} catch (final Exception e) {
- throw new RuntimeException("Error occurred while creating accessor for field \"" +
- cfgFieldName1 + "\", "+fieldType.getDebugString(), e);
+ throw new GlueGenException("Error occurred while creating accessor for field \"" +
+ cfgFieldName1 + "\", "+fieldType.getDebugString(), fieldType.getASTLocusTag(), e);
}
if( GlueGen.debug() ) {
- System.err.printf("SE.os.%02d: %s / %s, %s (%s)%n", (i+1), field, fieldName, fieldType.getDebugString(), "MISC");
+ System.err.printf("SE.os.%02d: %s / %s, %s (%s)%n", (i+1), field, cfgFieldName1, fieldType.getDebugString(), "MISC");
System.err.printf("SE.os.%02d: javaType %s%n", (i+1), externalJavaType.getDebugString());
}
if (externalJavaType.isPrimitive()) {
@@ -1160,8 +1165,9 @@ public class JavaEmitter implements GlueEmitter {
// FIXME: will need to support this at least in order to
// handle the union in jawt_Win32DrawingSurfaceInfo (fabricate a name?)
if (fieldType.getName() == null) {
- throw new RuntimeException("Anonymous structs as fields not supported yet (field \"" +
- field + "\" in type \"" + structCTypeName + "\")");
+ throw new GlueGenException("Anonymous structs as fields not supported yet (field \"" +
+ field + "\" in type \"" + structCTypeName + "\")",
+ fieldType.getASTLocusTag());
}
javaWriter.println();
generateGetterSignature(javaWriter, fieldType, false, false, fieldType.getName(), capitalizeString(fieldName), null, null);
@@ -1179,9 +1185,8 @@ public class JavaEmitter implements GlueEmitter {
try {
javaType = typeToJavaType(fieldType, machDescJava);
} catch (final Exception e) {
- LOG.log(SEVERE, "Error occurred while creating accessor for field \"{0}\", {1}",
- field.getName(), fieldType.getDebugString());
- throw(e);
+ throw new GlueGenException("Error occurred while creating accessor for field \"" +
+ field.getName() + "\", "+fieldType.getDebugString(), fieldType.getASTLocusTag(), e);
}
if (javaType.isPrimitive()) {
// Primitive type
@@ -1582,14 +1587,15 @@ public class JavaEmitter implements GlueEmitter {
final PrintWriter javaWriter, final PrintWriter jniWriter,
final String structCTypeName, final String structClassPkgName,
final Type containingCType, final JavaType containingJType,
- final int i, final Field field, final String fieldName, final String returnSizeLookupName) throws Exception {
+ final int i, final Field field, final String fieldName,
+ final String returnSizeLookupName) throws Exception {
final Type fieldType = field.getType();
final JavaType javaType;
try {
javaType = typeToJavaType(fieldType, machDescJava);
} catch (final Exception e) {
- throw new RuntimeException("Error occurred while creating array/pointer accessor for field \"" +
- returnSizeLookupName + "\", "+fieldType.getDebugString(), e);
+ throw new GlueGenException("Error occurred while creating array/pointer accessor for field \"" +
+ returnSizeLookupName + "\", "+fieldType.getDebugString(), fieldType.getASTLocusTag(), e);
}
if( GlueGen.debug() ) {
System.err.printf("SE.ac.%02d: javaType %s%n", (i+1), javaType.getDebugString());
@@ -1668,8 +1674,9 @@ public class JavaEmitter implements GlueEmitter {
try {
baseJElemType = typeToJavaType(baseCElemType, machDescJava);
} catch (final Exception e ) {
- throw new RuntimeException("Error occurred while creating array/pointer accessor for field \"" +
- returnSizeLookupName + "\", baseType "+baseCElemType.getDebugString()+", topType "+fieldType.getDebugString(), e);
+ throw new GlueGenException("Error occurred while creating array/pointer accessor for field \"" +
+ returnSizeLookupName + "\", baseType "+baseCElemType.getDebugString()+", topType "+fieldType.getDebugString(),
+ fieldType.getASTLocusTag(), e);
}
baseJElemTypeName = baseJElemType.getName();
baseCElemNativeSizeFixed = baseCElemType.isPrimitive() ? baseCElemType.getSize().hasFixedNativeSize() : true;
@@ -2073,8 +2080,9 @@ public class JavaEmitter implements GlueEmitter {
case 2: return javaType(Short.TYPE);
case 4: return javaType(Integer.TYPE);
case 8: return javaType(Long.TYPE);
- default: throw new RuntimeException("Unknown integer type of size " +
- cType.getSize(curMachDesc) + " and name " + cType.getName());
+ default: throw new GlueGenException("Unknown integer type of size " +
+ cType.getSize(curMachDesc) + " and name " + cType.getName(),
+ cType.getASTLocusTag());
}
} else if (cType.isFloat()) {
return javaType(Float.TYPE);
@@ -2109,8 +2117,9 @@ public class JavaEmitter implements GlueEmitter {
case 2: return JavaType.createForCShortPointer();
case 4: return JavaType.createForCInt32Pointer();
case 8: return JavaType.createForCInt64Pointer();
- default: throw new RuntimeException("Unknown integer array type of size " +
- cType.getSize(curMachDesc) + " and name " + cType.getName()+", "+cType.getDebugString());
+ default: throw new GlueGenException("Unknown integer array type of size " +
+ cType.getSize(curMachDesc) + " and name " + cType.getName()+", "+cType.getDebugString(),
+ cType.getASTLocusTag());
}
} else if (targetType.isFloat()) {
return JavaType.createForCFloatPointer();
@@ -2130,13 +2139,15 @@ public class JavaEmitter implements GlueEmitter {
// Try containing pointer type for any typedefs
name = cType.getName();
if (name == null) {
- throw new RuntimeException("Couldn't find a proper type name for pointer type " + cType.getDebugString());
+ throw new GlueGenException("Couldn't find a proper type name for pointer type " + cType.getDebugString(),
+ cType.getASTLocusTag());
}
}
return JavaType.createForCStruct(cfg.renameJavaType(name));
} else {
- throw new RuntimeException("Don't know how to convert pointer/array type \"" +
- cType.getDebugString() + "\"");
+ throw new GlueGenException("Don't know how to convert pointer/array type \"" +
+ cType.getDebugString() + "\"",
+ cType.getASTLocusTag());
}
}
// Handle Types of form pointer-to-pointer-to-type or
@@ -2179,16 +2190,17 @@ public class JavaEmitter implements GlueEmitter {
case 2: return javaType(ArrayTypes.shortBufferArrayClass);
case 4: return javaType(ArrayTypes.intBufferArrayClass);
case 8: return javaType(ArrayTypes.longBufferArrayClass);
- default: throw new RuntimeException("Unknown two-dimensional integer array type of element size " +
- bottomType.getSize(curMachDesc) + " and name " + bottomType.getName()+", "+bottomType.getDebugString());
+ default: throw new GlueGenException("Unknown two-dimensional integer array type of element size " +
+ bottomType.getSize(curMachDesc) + " and name " + bottomType.getName()+", "+bottomType.getDebugString(),
+ bottomType.getASTLocusTag());
}
} else if (bottomType.isFloat()) {
return javaType(ArrayTypes.floatBufferArrayClass);
} else if (bottomType.isDouble()) {
return javaType(ArrayTypes.doubleBufferArrayClass);
} else {
- throw new RuntimeException("Unexpected primitive type " + bottomType.getDebugString() +
- " in two-dimensional array");
+ throw new GlueGenException("Unexpected primitive type " + bottomType.getDebugString() +
+ " in two-dimensional array", bottomType.getASTLocusTag());
}
} else if (bottomType.isVoid()) {
return javaType(ArrayTypes.bufferArrayClass);
@@ -2197,32 +2209,38 @@ public class JavaEmitter implements GlueEmitter {
// Array of pointers; convert as array of StructAccessors
return JavaType.createForCArray(bottomType);
} else {
- throw new RuntimeException(
+ throw new GlueGenException(
"Could not convert C type \"" + cType.getDebugString() + "\" " +
"to appropriate Java type; need to add more support for " +
"depth=2 pointer/array types [debug info: targetType=\"" +
- targetType + "\"]");
+ targetType + "\"]", cType.getASTLocusTag());
}
} else {
// can't handle this type of pointer/array argument
- throw new RuntimeException(
+ throw new GlueGenException(
"Could not convert C pointer/array \"" + cType.getDebugString() + "\" to " +
"appropriate Java type; types with pointer/array depth " +
"greater than 2 are not yet supported [debug info: " +
"pointerDepth=" + cType.pointerDepth() + " arrayDimension=" +
- cType.arrayDimension() + " targetType=\"" + targetType + "\"]");
+ cType.arrayDimension() + " targetType=\"" + targetType + "\"]",
+ cType.getASTLocusTag());
}
- } else if(cType.isCompound() ) { // FIXME: Compound and Compound-Arrays
- final String name = cType.getName();
+ } else if( cType.isCompound() ) { // FIXME: Compound and Compound-Arrays
+ String name = cType.getName();
if (name == null) {
- throw new RuntimeException("Couldn't find a proper type name for pointer type " + cType.getDebugString());
+ name = cType.asCompound().getStructName();
+ if (name == null) {
+ throw new GlueGenException("Couldn't find a proper type name for pointer type " + cType.getDebugString(),
+ cType.getASTLocusTag());
+ }
}
return JavaType.createForCStruct(cfg.renameJavaType(name));
} else {
- throw new RuntimeException(
+ throw new GlueGenException(
"Could not convert C type \"" + cType.getDebugString() + "\" (class " +
- cType.getClass().getName() + ") to appropriate Java type");
+ cType.getClass().getName() + ") to appropriate Java type",
+ cType.getASTLocusTag());
}
}
@@ -2258,7 +2276,7 @@ public class JavaEmitter implements GlueEmitter {
}
private boolean isOpaque(final Type type) {
- return (cfg.typeInfo(type) != null);
+ return null != cfg.typeInfo(type);
}
private String compatiblePrimitiveJavaTypeName(final Type fieldType,
@@ -2267,14 +2285,16 @@ public class JavaEmitter implements GlueEmitter {
final Class<?> c = javaType.getJavaClass();
if (!isIntegerType(c)) {
// FIXME
- throw new RuntimeException("Can't yet handle opaque definitions of structs' fields to non-integer types (byte, short, int, long, etc.): type: "+fieldType+", javaType "+javaType+", javaClass "+c);
+ throw new GlueGenException("Can't yet handle opaque definitions of structs' fields to non-integer types (byte, short, int, long, etc.): type: "+fieldType+", javaType "+javaType+", javaClass "+c,
+ fieldType.getASTLocusTag());
}
switch ((int) fieldType.getSize(curMachDesc)) {
case 1: return "byte";
case 2: return "short";
case 4: return "int";
case 8: return "long";
- default: throw new RuntimeException("Can't handle opaque definitions if the starting type isn't compatible with integral types");
+ default: throw new GlueGenException("Can't handle opaque definitions if the starting type isn't compatible with integral types",
+ fieldType.getASTLocusTag());
}
}
@@ -2662,9 +2682,10 @@ public class JavaEmitter implements GlueEmitter {
if (prt == null ||
prt.getTargetType().asInt() == null ||
prt.getTargetType().getSize(curMachDesc) != 1) {
- throw new RuntimeException(
+ throw new GlueGenException(
"Cannot apply ReturnsString configuration directive to \"" + sym +
- "\". ReturnsString requires native method to have return type \"char *\"");
+ "\". ReturnsString requires native method to have return type \"char *\"",
+ sym.getASTLocusTag());
}
binding.setJavaReturnType(javaType(java.lang.String.class));
} else {
@@ -2703,10 +2724,11 @@ public class JavaEmitter implements GlueEmitter {
}
}
else {
- throw new RuntimeException(
+ throw new GlueGenException(
"Cannot apply ArgumentIsString configuration directive to " +
"argument " + i + " of \"" + sym + "\": argument type is not " +
- "a \"void*\", \"char *\", \"short *\", \"char**\", or \"short**\" equivalent");
+ "a \"void*\", \"char *\", \"short *\", \"char**\", or \"short**\" equivalent",
+ sym.getASTLocusTag());
}
}
binding.addJavaArgumentType(mappedType);
@@ -2776,7 +2798,7 @@ public class JavaEmitter implements GlueEmitter {
result = result.replaceJavaArgumentType(i, JavaType.forNIODoubleBufferClass());
}
} else {
- throw new RuntimeException("Unknown C pointer type " + t);
+ throw new GlueGenException("Unknown C pointer type " + t);
}
}
}
@@ -2801,7 +2823,7 @@ public class JavaEmitter implements GlueEmitter {
} else if (t.isCDoublePointerType()) {
result = result.replaceJavaArgumentType(-1, JavaType.forNIODoubleBufferClass());
} else {
- throw new RuntimeException("Unknown C pointer type " + t);
+ throw new GlueGenException("Unknown C pointer type " + t, result.getCReturnType().getASTLocusTag());
}
}
diff --git a/src/java/com/jogamp/gluegen/ReferencedStructs.java b/src/java/com/jogamp/gluegen/ReferencedStructs.java
index 546726f..46a2a7e 100644
--- a/src/java/com/jogamp/gluegen/ReferencedStructs.java
+++ b/src/java/com/jogamp/gluegen/ReferencedStructs.java
@@ -58,7 +58,7 @@ public class ReferencedStructs implements TypeVisitor {
public void visitType(final Type t) {
if (t.isPointer()) {
final PointerType p = t.asPointer();
- if (p.hasTypedefName()) {
+ if (p.isTypedef()) {
final CompoundType c = p.getTargetType().asCompound();
if (c != null && c.getName() == null) {
// This otherwise-unnamed CompoundType is referred to by a
diff --git a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
index 281c68d..672bccf 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/ArrayType.java
@@ -40,6 +40,8 @@
package com.jogamp.gluegen.cgram.types;
+import com.jogamp.gluegen.ASTLocusTag;
+
/** 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
@@ -49,8 +51,13 @@ public class ArrayType extends MemoryLayoutType implements Cloneable {
private final Type elementType;
private final int length;
- public ArrayType(final Type elementType, final SizeThunk sizeInBytes, final int length, final int cvAttributes) {
- super(elementType.getName() + " *", sizeInBytes, cvAttributes);
+ public ArrayType(final Type elementType, final SizeThunk sizeInBytes, final int length,
+ final int cvAttributes) {
+ this(elementType, sizeInBytes, length, cvAttributes, null);
+ }
+ public ArrayType(final Type elementType, final SizeThunk sizeInBytes, final int length,
+ final int cvAttributes, final ASTLocusTag astLocus) {
+ super(elementType.getName() + " *", sizeInBytes, cvAttributes, astLocus);
this.elementType = elementType;
this.length = length;
}
@@ -147,6 +154,10 @@ public class ArrayType extends MemoryLayoutType implements Cloneable {
@Override
Type newCVVariant(final int cvAttributes) {
- return new ArrayType(elementType, getSize(), length, cvAttributes);
+ final Type t = new ArrayType(elementType, getSize(), length, cvAttributes, astLocus);
+ if( isTypedef() ) {
+ t.setTypedef(getTypedefCVAttributes());
+ }
+ return t;
}
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/BitType.java b/src/java/com/jogamp/gluegen/cgram/types/BitType.java
index 87eb8ce..b7488ea 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/BitType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/BitType.java
@@ -40,7 +40,7 @@
package com.jogamp.gluegen.cgram.types;
-import com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp;
+import com.jogamp.gluegen.ASTLocusTag;
/** Represents a bitfield in a struct. */
@@ -49,8 +49,9 @@ public class BitType extends IntType implements Cloneable {
private final int sizeInBits;
private final int offset;
- public BitType(final IntType underlyingType, final int sizeInBits, final int lsbOffset, final int cvAttributes) {
- super(underlyingType.getName(), underlyingType.getSize(), underlyingType.isUnsigned(), cvAttributes);
+ public BitType(final IntType underlyingType, final int sizeInBits, final int lsbOffset,
+ final int cvAttributes, final ASTLocusTag astLocus) {
+ super(underlyingType.getName(), underlyingType.getSize(), underlyingType.isUnsigned(), cvAttributes, astLocus);
this.underlyingType = underlyingType;
this.sizeInBits = sizeInBits;
this.offset = lsbOffset;
@@ -110,6 +111,10 @@ public class BitType extends IntType implements Cloneable {
@Override
Type newCVVariant(final int cvAttributes) {
- return new BitType(underlyingType, sizeInBits, offset, cvAttributes);
+ final Type t = new BitType(underlyingType, sizeInBits, offset, cvAttributes, astLocus);
+ if( isTypedef() ) {
+ t.setTypedef(getTypedefCVAttributes());
+ }
+ return t;
}
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java b/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java
index c9c4223..264389b 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/CompoundType.java
@@ -42,6 +42,8 @@ package com.jogamp.gluegen.cgram.types;
import java.util.*;
+import com.jogamp.gluegen.ASTLocusTag;
+
/** Models all compound types, i.e., those containing fields: structs
and unions. The boolean type accessors indicate how the type is
really defined. */
@@ -59,8 +61,9 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable
* @param cvAttributes
* @param structName
*/
- CompoundType(final String name, final SizeThunk size, final int cvAttributes, final String structName) {
- super(name, size, cvAttributes);
+ CompoundType(final String name, final SizeThunk size, final int cvAttributes,
+ final String structName, final ASTLocusTag astLocus) {
+ super(name, size, cvAttributes, astLocus);
this.structName = structName;
}
@@ -96,15 +99,17 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable
* @param cvAttributes
* @return
*/
- public static CompoundType create(final String structName, final SizeThunk size, final CompoundTypeKind kind, final int cvAttributes)
+ public static CompoundType create(final String structName, final SizeThunk size,
+ final CompoundTypeKind kind, final int cvAttributes,
+ final ASTLocusTag astLocus)
{
final CompoundType res;
switch (kind) {
case STRUCT:
- res = new StructType(null, size, cvAttributes, structName);
+ res = new StructType(null, size, cvAttributes, structName, astLocus);
break;
case UNION:
- res = new UnionType(null, size, cvAttributes, structName);
+ res = new UnionType(null, size, cvAttributes, structName, astLocus);
break;
default:
throw new RuntimeException("OO relation "+kind+" / Compount not yet supported");
@@ -165,7 +170,7 @@ public abstract class CompoundType extends MemoryLayoutType implements Cloneable
@Override
public String getCName(final boolean includeCVAttrs) {
- if( hasTypedefName() ) {
+ if( isTypedef() ) {
return getName(includeCVAttrs);
} else {
return (isStruct() ? "struct " : "union ")+getName(includeCVAttrs);
diff --git a/src/java/com/jogamp/gluegen/cgram/types/DoubleType.java b/src/java/com/jogamp/gluegen/cgram/types/DoubleType.java
index 1e13701..7bcf767 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/DoubleType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/DoubleType.java
@@ -39,11 +39,13 @@
*/
package com.jogamp.gluegen.cgram.types;
+import com.jogamp.gluegen.ASTLocusTag;
+
/** Represents a double-word floating-point type (C type "double".) */
public class DoubleType extends PrimitiveType implements Cloneable {
- public DoubleType(final String name, final SizeThunk size, final int cvAttributes) {
- super(name, size, cvAttributes);
+ public DoubleType(final String name, final SizeThunk size, final int cvAttributes, final ASTLocusTag astLocus) {
+ super(name, size, cvAttributes, astLocus);
}
@Override
@@ -73,6 +75,10 @@ public class DoubleType extends PrimitiveType implements Cloneable {
@Override
Type newCVVariant(final int cvAttributes) {
- return new DoubleType(getName(), getSize(), cvAttributes);
+ final Type t = new DoubleType(getName(), getSize(), cvAttributes, astLocus);
+ if( isTypedef() ) {
+ t.setTypedef(getTypedefCVAttributes());
+ }
+ return t;
}
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/EnumType.java b/src/java/com/jogamp/gluegen/cgram/types/EnumType.java
index 7fa22e4..47691cd 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/EnumType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/EnumType.java
@@ -43,13 +43,12 @@ import java.util.ArrayList;
import java.util.NoSuchElementException;
import com.jogamp.gluegen.ASTLocusTag;
-import com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider;
import com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp;
/** Describes enumerated types. Enumerations are like ints except that
they have a set of named values. */
-public class EnumType extends IntType implements Cloneable, ASTLocusTagProvider {
+public class EnumType extends IntType implements Cloneable {
private IntType underlyingType;
@@ -103,30 +102,23 @@ public class EnumType extends IntType implements Cloneable, ASTLocusTagProvider
}
private ArrayList<Enum> enums;
- private final ASTLocusTag astLocus;
public EnumType(final String name) {
super(name, SizeThunk.LONG, false, CVAttributes.CONST);
this.underlyingType = new IntType(name, SizeThunk.LONG, false, CVAttributes.CONST);
- this.astLocus = null;
}
public EnumType(final String name, final SizeThunk enumSizeInBytes, final ASTLocusTag astLocus) {
- super(name, enumSizeInBytes, false, CVAttributes.CONST);
- this.underlyingType = new IntType(name, enumSizeInBytes, false, CVAttributes.CONST);
- this.astLocus = astLocus;
+ super(name, enumSizeInBytes, false, CVAttributes.CONST, astLocus);
+ this.underlyingType = new IntType(name, enumSizeInBytes, false, CVAttributes.CONST, astLocus);
}
protected EnumType(final String name, final IntType underlyingType, final int cvAttributes, final ASTLocusTag astLocus) {
- super(name, underlyingType.getSize(), underlyingType.isUnsigned(), cvAttributes);
+ super(name, underlyingType.getSize(), underlyingType.isUnsigned(), cvAttributes, astLocus);
this.underlyingType = underlyingType;
- this.astLocus = astLocus;
}
@Override
- public ASTLocusTag getASTLocusTag() { return astLocus; }
-
- @Override
public Object clone() {
final EnumType n = (EnumType) super.clone();
if(null!=this.underlyingType) {
@@ -255,6 +247,9 @@ public class EnumType extends IntType implements Cloneable, ASTLocusTagProvider
Type newCVVariant(final int cvAttributes) {
final EnumType t = new EnumType(getName(), underlyingType, cvAttributes, astLocus);
t.enums = enums;
+ if( isTypedef() ) {
+ t.setTypedef(getTypedefCVAttributes());
+ }
return t;
}
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/FloatType.java b/src/java/com/jogamp/gluegen/cgram/types/FloatType.java
index 0428543..2632409 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/FloatType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/FloatType.java
@@ -40,11 +40,13 @@
package com.jogamp.gluegen.cgram.types;
+import com.jogamp.gluegen.ASTLocusTag;
+
/** Represents a single-word floating-point type (C type "float".) */
public class FloatType extends PrimitiveType implements Cloneable {
- public FloatType(final String name, final SizeThunk size, final int cvAttributes) {
- super(name, size, cvAttributes);
+ public FloatType(final String name, final SizeThunk size, final int cvAttributes, final ASTLocusTag astLocus) {
+ super(name, size, cvAttributes, astLocus);
}
@Override
@@ -72,6 +74,10 @@ public class FloatType extends PrimitiveType implements Cloneable {
@Override
Type newCVVariant(final int cvAttributes) {
- return new FloatType(getName(), getSize(), cvAttributes);
+ final Type t = new FloatType(getName(), getSize(), cvAttributes, astLocus);
+ if( isTypedef() ) {
+ t.setTypedef(getTypedefCVAttributes());
+ }
+ return t;
}
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java b/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java
index b0d16e1..7ccc4c0 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/FunctionType.java
@@ -41,7 +41,7 @@ package com.jogamp.gluegen.cgram.types;
import java.util.*;
-import com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp;
+import com.jogamp.gluegen.ASTLocusTag;
/** Describes a function type, used to model both function
declarations and (via PointerType) function pointers. */
@@ -51,8 +51,13 @@ public class FunctionType extends Type implements Cloneable {
private ArrayList<Type> argumentTypes;
private ArrayList<String> argumentNames;
- public FunctionType(final String name, final SizeThunk size, final Type returnType, final int cvAttributes) {
- super(name, size, cvAttributes);
+ public FunctionType(final String name, final SizeThunk size, final Type returnType,
+ final int cvAttributes) {
+ this(name, size, returnType, cvAttributes, null);
+ }
+ public FunctionType(final String name, final SizeThunk size, final Type returnType,
+ final int cvAttributes, final ASTLocusTag astLocus) {
+ super(name, size, cvAttributes, astLocus);
this.returnType = returnType;
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/MemoryLayoutType.java b/src/java/com/jogamp/gluegen/cgram/types/MemoryLayoutType.java
index fb8c86b..ba46aed 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/MemoryLayoutType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/MemoryLayoutType.java
@@ -27,11 +27,13 @@
*/
package com.jogamp.gluegen.cgram.types;
+import com.jogamp.gluegen.ASTLocusTag;
+
public abstract class MemoryLayoutType extends Type {
private boolean isLayouted;
- protected MemoryLayoutType(final String name, final SizeThunk size, final int cvAttributes) {
- super(name, size, cvAttributes);
+ protected MemoryLayoutType(final String name, final SizeThunk size, final int cvAttributes, final ASTLocusTag astLocus) {
+ super(name, size, cvAttributes, astLocus);
isLayouted = false;
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java b/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
index c6496bb..1528f9f 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/PointerType.java
@@ -39,18 +39,20 @@
*/
package com.jogamp.gluegen.cgram.types;
+import com.jogamp.gluegen.ASTLocusTag;
+
public class PointerType extends Type implements Cloneable {
private final Type targetType;
- public PointerType(final SizeThunk size, final Type targetType, final int cvAttributes, final String typedefedName) {
+ public PointerType(final SizeThunk size, final Type targetType, final int cvAttributes) {
+ this(size, targetType, cvAttributes, null);
+ }
+ public PointerType(final SizeThunk size, final Type targetType, final int cvAttributes, final ASTLocusTag astLocus) {
// can pass null for the final name parameter because the PointerType's getName()
// completely replaces superclass behavior
- super(targetType.getName() + " *", size, cvAttributes);
+ super(targetType.getName() + " *", size, cvAttributes, astLocus);
this.targetType = targetType;
- if (null != typedefedName) {
- setTypedefName(typedefedName);
- }
}
@Override
@@ -77,7 +79,7 @@ public class PointerType extends Type implements Cloneable {
@Override
public boolean hasName() {
- if ( hasTypedefName() ) {
+ if ( isTypedef() ) {
return super.hasName();
} else {
return targetType.hasName();
@@ -86,7 +88,7 @@ public class PointerType extends Type implements Cloneable {
@Override
public String getName(final boolean includeCVAttrs) {
- if ( hasTypedefName() ) {
+ if ( isTypedef() ) {
return super.getName(includeCVAttrs);
} else if (!includeCVAttrs) {
return targetType.getName(includeCVAttrs) + " *";
@@ -97,7 +99,7 @@ public class PointerType extends Type implements Cloneable {
@Override
public String getCName(final boolean includeCVAttrs) {
- if ( hasTypedefName() ) {
+ if ( isTypedef() ) {
return super.getCName(includeCVAttrs);
} else if (!includeCVAttrs) {
return targetType.getCName(includeCVAttrs) + " *";
@@ -134,7 +136,7 @@ public class PointerType extends Type implements Cloneable {
@Override
public String toString() {
- if ( hasTypedefName() ) {
+ if ( isTypedef() ) {
return super.getCName(true);
} else {
return toStringInt();
@@ -167,6 +169,10 @@ public class PointerType extends Type implements Cloneable {
@Override
Type newCVVariant(final int cvAttributes) {
- return new PointerType(getSize(), targetType, cvAttributes, (hasTypedefName() ? getName() : null));
+ final Type t = new PointerType(getSize(), targetType, cvAttributes, astLocus);
+ if( isTypedef() ) {
+ t.setTypedef(getName(), getTypedefCVAttributes());
+ }
+ return t;
}
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java b/src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java
index 8a86337..69e28ab 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/PrimitiveType.java
@@ -39,10 +39,12 @@
*/
package com.jogamp.gluegen.cgram.types;
+import com.jogamp.gluegen.ASTLocusTag;
+
public abstract class PrimitiveType extends Type implements Cloneable {
- protected PrimitiveType(final String name, final SizeThunk size, final int cvAttributes) {
- super(name, size, cvAttributes);
+ protected PrimitiveType(final String name, final SizeThunk size, final int cvAttributes, final ASTLocusTag astLocus) {
+ super(name, size, cvAttributes, astLocus);
}
@Override
diff --git a/src/java/com/jogamp/gluegen/cgram/types/StructType.java b/src/java/com/jogamp/gluegen/cgram/types/StructType.java
index 4998484..7f2f865 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/StructType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/StructType.java
@@ -27,14 +27,12 @@
*/
package com.jogamp.gluegen.cgram.types;
-public class StructType extends CompoundType {
+import com.jogamp.gluegen.ASTLocusTag;
- public StructType(final String name, final SizeThunk size, final int cvAttributes) {
- this(name, size, cvAttributes, null);
- }
+public class StructType extends CompoundType {
- StructType(final String name, final SizeThunk size, final int cvAttributes, final String structName) {
- super (name, size, cvAttributes, structName);
+ StructType(final String name, final SizeThunk size, final int cvAttributes, final String structName, final ASTLocusTag astLocus) {
+ super (name, size, cvAttributes, structName, astLocus);
}
@Override
@@ -44,10 +42,10 @@ public class StructType extends CompoundType {
@Override
Type newCVVariant(final int cvAttributes) {
- final StructType t = new StructType(getName(), getSize(), cvAttributes, getStructName());
+ final StructType t = new StructType(getName(), getSize(), cvAttributes, getStructName(), astLocus);
t.setFields(getFields());
- if( hasTypedefName() ) {
- t.setTypedefName( getName() );
+ if( isTypedef() ) {
+ t.setTypedef(getTypedefCVAttributes());
}
return t;
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/Type.java b/src/java/com/jogamp/gluegen/cgram/types/Type.java
index cd48aa0..9fd51fe 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/Type.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/Type.java
@@ -41,6 +41,8 @@
package com.jogamp.gluegen.cgram.types;
import com.jogamp.common.os.MachineDataInfo;
+import com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider;
+import com.jogamp.gluegen.ASTLocusTag;
import com.jogamp.gluegen.GlueGen;
import com.jogamp.gluegen.TypeConfig;
import com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp;
@@ -49,36 +51,34 @@ import com.jogamp.gluegen.cgram.types.TypeComparator.SemanticEqualityOp;
double. All types have an associated name. Structs and unions are
modeled as "compound" types -- composed of fields of primitive or
other types. */
-public abstract class Type implements Cloneable, SemanticEqualityOp {
+public abstract class Type implements Cloneable, SemanticEqualityOp, ASTLocusTagProvider {
public final boolean relaxedEqSem;
private final int cvAttributes;
private String name;
private SizeThunk size;
- private int typedefedCVAttributes;
- private boolean hasTypedefName;
+ private int typedefCVAttributes;
+ private boolean isTypedef;
private boolean hasCachedHash;
private int cachedHash;
private boolean hasCachedSemanticHash;
private int cachedSemanticHash;
+ final ASTLocusTag astLocus;
- protected Type(final String name, final SizeThunk size, final int cvAttributes) {
- setName(name);
+ protected Type(final String name, final SizeThunk size, final int cvAttributes, final ASTLocusTag astLocus) {
+ setName(name); // -> clearCache()
this.relaxedEqSem = TypeConfig.relaxedEqualSemanticsTest();
this.cvAttributes = cvAttributes;
this.size = size;
- this.typedefedCVAttributes = 0;
- this.hasTypedefName = false;
- this.hasCachedHash = false;
- this.cachedHash = 0;
- this.hasCachedSemanticHash = false;
- this.cachedSemanticHash = 0;
+ this.typedefCVAttributes = 0;
+ this.isTypedef = false;
+ this.astLocus = astLocus;
}
protected final void clearCache() {
- cachedHash = 0;
hasCachedHash = false;
+ cachedHash = 0;
+ hasCachedSemanticHash = false;
cachedSemanticHash = 0;
- hasCachedHash = false;
}
@Override
@@ -90,6 +90,9 @@ public abstract class Type implements Cloneable, SemanticEqualityOp {
}
}
+ @Override
+ public final ASTLocusTag getASTLocusTag() { return astLocus; }
+
public final boolean isAnonymous() { return null == name; }
public boolean hasName() { return null != name; }
@@ -139,11 +142,15 @@ public abstract class Type implements Cloneable, SemanticEqualityOp {
}
// For debugging
public String getDebugString() {
+ return getDebugString(false);
+ }
+ // For debugging
+ public String getDebugString(final boolean withASTLoc) {
final StringBuilder sb = new StringBuilder();
boolean prepComma = false;
sb.append("CType[");
sb.append("(").append(getClass().getSimpleName()).append(") ");
- if( hasTypedefName() ) {
+ if( isTypedef() ) {
sb.append("typedef ");
}
if( null != name ) {
@@ -223,34 +230,85 @@ public abstract class Type implements Cloneable, SemanticEqualityOp {
if( isVoid() ) {
append(sb, "void", prepComma); prepComma=true;
}
- sb.append("]]");
+ sb.append("]");
+ if( withASTLoc ) {
+ sb.append(", loc ").append(astLocus);
+ }
+ sb.append("]");
return sb.toString();
}
private final int objHash() { return super.hashCode(); }
- protected final void setName(final String name) {
- if (name == null) {
+ /**
+ * Returns {@code true} if given {@code name} is not {@code null}
+ * and has a length &gt; 0. In this case this instance's names will
+ * be set to the internalized version.
+ * <p>
+ * Otherwise method returns {@code false}
+ * and this instance's name will be set to {@code null}.
+ * </p>
+ * <p>
+ * Method issues {@link #clearCache()}, to force re-evaluation
+ * of hashes.
+ * </p>
+ */
+ protected final boolean setName(final String name) {
+ clearCache();
+ if( null == name || 0 == name.length() ) {
this.name = name;
+ return false;
} else {
this.name = name.intern();
+ return true;
}
- clearCache();
}
- /** Set the name of this type; used for handling typedefs. */
+ /**
+ * Set the typedef name of this type and renders this type a typedef,
+ * if given {@code name} has a length.
+ * <p>
+ * Method issues {@link #clearCache()}, to force re-evaluation
+ * of hashes.
+ * </p>
+ */
public void setTypedefName(final String name) {
- setName(name);
- // Capture the const/volatile attributes at the time of typedef so
- // we don't redundantly repeat them in the CV attributes string
- typedefedCVAttributes = cvAttributes;
- hasTypedefName = true;
+ if( setName(name) ) {
+ // Capture the const/volatile attributes at the time of typedef so
+ // we don't redundantly repeat them in the CV attributes string
+ typedefCVAttributes = cvAttributes;
+ isTypedef = true;
+ }
+ }
+ /**
+ * Set the typedef name of this type and renders this type a typedef,
+ * if given {@code name} has a length.
+ * <p>
+ * Method issues {@link #clearCache()}, to force re-evaluation
+ * of hashes.
+ * </p>
+ */
+ final void setTypedef(final String name, final int typedefedCVAttributes) {
+ if( setName(name) ) {
+ this.typedefCVAttributes = typedefedCVAttributes;
+ this.isTypedef = true;
+ }
+ }
+ final void setTypedef(final int typedefedCVAttributes) {
+ this.typedefCVAttributes = typedefedCVAttributes;
+ this.isTypedef = true;
+ clearCache();
+ }
+ final int getTypedefCVAttributes() {
+ return typedefCVAttributes;
}
- /** Indicates whether {@link #setTypedefName(String)} has been called on this type,
- indicating that it already has a typedef name. */
- public final boolean hasTypedefName() {
- return hasTypedefName;
+ /**
+ * Indicates whether this type is a typedef type,
+ * i.e. declared via {@link #setTypedefName(String)}.
+ */
+ public final boolean isTypedef() {
+ return isTypedef;
}
/** SizeThunk which computes size of this type in bytes. */
@@ -312,9 +370,9 @@ public abstract class Type implements Cloneable, SemanticEqualityOp {
public boolean isVoid() { return (asVoid() != null); }
/** Indicates whether this type is const. */
- public boolean isConst() { return (((cvAttributes & ~typedefedCVAttributes) & CVAttributes.CONST) != 0); }
+ public boolean isConst() { return (((cvAttributes & ~typedefCVAttributes) & CVAttributes.CONST) != 0); }
/** Indicates whether this type is volatile. */
- public boolean isVolatile() { return (((cvAttributes & ~typedefedCVAttributes) & CVAttributes.VOLATILE) != 0); }
+ public boolean isVolatile() { return (((cvAttributes & ~typedefCVAttributes) & CVAttributes.VOLATILE) != 0); }
/** Indicates whether this type is a primitive type. */
public boolean isPrimitive(){ return false; }
@@ -330,11 +388,11 @@ public abstract class Type implements Cloneable, SemanticEqualityOp {
public final int hashCode() {
if( !hasCachedHash ) {
// 31 * x == (x << 5) - x
- int hash = 31 + ( hasTypedefName ? 1 : 0 );
+ int hash = 31 + ( isTypedef ? 1 : 0 );
hash = ((hash << 5) - hash) + ( null != size ? size.hashCode() : 0 );
hash = ((hash << 5) - hash) + cvAttributes;
hash = ((hash << 5) - hash) + ( null != name ? name.hashCode() : 0 );
- if( !hasTypedefName ) {
+ if( !isTypedef ) {
hash = ((hash << 5) - hash) + hashCodeImpl();
}
cachedHash = hash;
@@ -355,7 +413,7 @@ public abstract class Type implements Cloneable, SemanticEqualityOp {
return false;
} else {
final Type t = (Type)arg;
- if( hasTypedefName == t.hasTypedefName &&
+ if( isTypedef == t.isTypedef &&
( ( null != size && size.equals(t.size) ) ||
( null == size && null == t.size )
) &&
@@ -363,7 +421,7 @@ public abstract class Type implements Cloneable, SemanticEqualityOp {
( null == name ? null == t.name : name.equals(t.name) )
)
{
- if( !hasTypedefName ) {
+ if( !isTypedef ) {
return equalsImpl(t);
} else {
return true;
diff --git a/src/java/com/jogamp/gluegen/cgram/types/UnionType.java b/src/java/com/jogamp/gluegen/cgram/types/UnionType.java
index 6ccc4a2..e03d671 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/UnionType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/UnionType.java
@@ -27,14 +27,12 @@
*/
package com.jogamp.gluegen.cgram.types;
-public class UnionType extends CompoundType {
+import com.jogamp.gluegen.ASTLocusTag;
- public UnionType(final String name, final SizeThunk size, final int cvAttributes) {
- this(name, size, cvAttributes, null);
- }
+public class UnionType extends CompoundType {
- UnionType(final String name, final SizeThunk size, final int cvAttributes, final String structName) {
- super (name, size, cvAttributes, structName);
+ UnionType(final String name, final SizeThunk size, final int cvAttributes, final String structName, final ASTLocusTag astLocus) {
+ super (name, size, cvAttributes, structName, astLocus);
}
@Override
@@ -44,10 +42,10 @@ public class UnionType extends CompoundType {
@Override
Type newCVVariant(final int cvAttributes) {
- final UnionType t = new UnionType(getName(), getSize(), cvAttributes, getStructName());
+ final UnionType t = new UnionType(getName(), getSize(), cvAttributes, getStructName(), astLocus);
t.setFields(getFields());
- if( hasTypedefName() ) {
- t.setTypedefName( getName() );
+ if( isTypedef() ) {
+ t.setTypedef(getTypedefCVAttributes());
}
return t;
}
diff --git a/src/java/com/jogamp/gluegen/cgram/types/VoidType.java b/src/java/com/jogamp/gluegen/cgram/types/VoidType.java
index f6adaac..f63bda3 100644
--- a/src/java/com/jogamp/gluegen/cgram/types/VoidType.java
+++ b/src/java/com/jogamp/gluegen/cgram/types/VoidType.java
@@ -39,14 +39,16 @@
*/
package com.jogamp.gluegen.cgram.types;
+import com.jogamp.gluegen.ASTLocusTag;
+
public class VoidType extends Type implements Cloneable {
- public VoidType(final int cvAttributes) {
- this("void", cvAttributes);
+ public VoidType(final int cvAttributes, final ASTLocusTag astLocus) {
+ this("void", cvAttributes, astLocus);
}
- private VoidType(final String name, final int cvAttributes) {
- super(name, null, cvAttributes);
+ private VoidType(final String name, final int cvAttributes, final ASTLocusTag astLocus) {
+ super(name, null, cvAttributes, astLocus);
}
@Override
@@ -56,7 +58,11 @@ public class VoidType extends Type implements Cloneable {
@Override
Type newCVVariant(final int cvAttributes) {
- return new VoidType(getName(), cvAttributes);
+ final Type t = new VoidType(getName(), cvAttributes, astLocus);
+ if( isTypedef() ) {
+ t.setTypedef(getTypedefCVAttributes());
+ }
+ return t;
}
@Override
diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
index 982e16d..09e6822 100644
--- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
+++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressCMethodBindingEmitter.java
@@ -134,7 +134,7 @@ public class ProcAddressCMethodBindingEmitter extends CMethodBindingEmitter {
// We (probably) didn't get a typedef for this function
// pointer type in the header file; the user requested that we
// forcibly generate one. Here we force the emission of one.
- final PointerType funcPtrType = new PointerType(null, cSym.getType(), 0, null);
+ final PointerType funcPtrType = new PointerType(null, cSym.getType(), 0);
// Just for safety, emit this name slightly differently than
// the mangling would otherwise produce
funcPointerTypedefName = "_local_" + funcPointerTypedefName;
diff --git a/src/java/com/jogamp/gluegen/structgen/CStructAnnotationProcessor.java b/src/java/com/jogamp/gluegen/structgen/CStructAnnotationProcessor.java
index c4dedb7..7ccfd1b 100644
--- a/src/java/com/jogamp/gluegen/structgen/CStructAnnotationProcessor.java
+++ b/src/java/com/jogamp/gluegen/structgen/CStructAnnotationProcessor.java
@@ -131,7 +131,11 @@ public class CStructAnnotationProcessor extends AbstractProcessor {
if( f.exists() ) {
return f;
}
- } catch (final IOException e) { if(DEBUG) { System.err.println("Caught "+e.getClass().getSimpleName()+": "+e.getMessage()); /* e.printStackTrace(); */ } }
+ } catch (final IOException e) {
+ if(DEBUG) {
+ System.err.println("Caught "+e.getClass().getSimpleName()+": "+e.getMessage()); /* e.printStackTrace(); */
+ }
+ }
return null;
}
@@ -263,6 +267,9 @@ public class CStructAnnotationProcessor extends AbstractProcessor {
} catch (final FileNotFoundException ex) {
throw new RuntimeException("input file not found", ex);
}
+ if( DEBUG ) {
+ GlueGen.setDebug(true);
+ }
new GlueGen().run(reader, filename, AnnotationProcessorJavaStructEmitter.class,
includePaths, cfgFiles, outputPath1, false /* copyCPPOutput2Stderr */);
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
index 1b97437..8bc7208 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
+++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test1.h
@@ -365,7 +365,7 @@ typedef struct {
const int32_t structPointerCustomLenVal;
const TK_Dimension * structPointerOneElem;
- const TK_Context ctx;
+ TK_Context ctx;
const char modelNameArrayFixedLen[12]; /* 'Hello Array' len=11+1 */
const char * modelNamePointerCString; /* 'Hello CString' len=13+1 */
diff --git a/src/junit/com/jogamp/gluegen/test/junit/internals/TestType.java b/src/junit/com/jogamp/gluegen/test/junit/internals/TestType.java
index 1b83d0c..84fc463 100644
--- a/src/junit/com/jogamp/gluegen/test/junit/internals/TestType.java
+++ b/src/junit/com/jogamp/gluegen/test/junit/internals/TestType.java
@@ -43,10 +43,10 @@ public class TestType extends SingletonJunitCase {
@Test
public void test01Equals() {
- final FloatType f1 = new FloatType("GLfloat", null, 0);
- final FloatType f2 = new FloatType("float", null, 0);
- final IntType i1 = new IntType("GLint", null, false, 0);
- final IntType i2 = new IntType("int", null, false, 0);
+ final FloatType f1 = new FloatType("GLfloat", null, 0, null);
+ final FloatType f2 = new FloatType("float", null, 0, null);
+ final IntType i1 = new IntType("GLint", null, false, 0, null);
+ final IntType i2 = new IntType("int", null, false, 0, null);
final int f1H = f1.hashCode();
final int f2H = f2.hashCode();
final int i1H = i1.hashCode();