From 187c097055dc691a2ee65bed1c06c089aaf5cb59 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 18 Jun 2023 03:35:43 +0200 Subject: GlueGen Struct [12]: Throw InternalError(..) for produced code-path where Ownership.Native _and_ native memory potentially gets replaced --- src/java/com/jogamp/gluegen/JavaEmitter.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/java') diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java index eee1f9d..917ff35 100644 --- a/src/java/com/jogamp/gluegen/JavaEmitter.java +++ b/src/java/com/jogamp/gluegen/JavaEmitter.java @@ -1868,6 +1868,9 @@ public class JavaEmitter implements GlueEmitter { null, constElemCount, maxOneElement, elemCountExpr, null, null); if( isConstValue ) { // constElemCount/Ownership.Native excluded: SKIP setter for constValue constElemCount Pointer w/ native ownership + if( Ownership.Native == ownership ) { + throw new InternalError("Native ownership but adding potential memory-replacement for '"+returnSizeLookupName+"': "+fieldType.getSignature(null).toString()); + } unit.emitln(" {"); unit.emitln(" final ElementBuffer eb = ElementBuffer.allocateDirect("+primElemSizeExpr+", 1);"); unit.emit (" eb.getByteBuffer()"); @@ -1962,6 +1965,9 @@ public class JavaEmitter implements GlueEmitter { // constElemCount/Ownership.Native excluded: SKIP setter for constValue constElemCount Pointer w/ native ownership generateSetterSignature(unit, accessMod, false, false, fieldName, fieldType, ownership, containingJTypeName, capitalFieldName, null, baseJElemTypeName+"[]", SetReplaceArrayArgsPost, constElemCount, maxOneElement, elemCountExpr, SetReplaceArrayApiDocDetail, SetReplaceArrayApiDocArgs); + if( Ownership.Native == ownership ) { + throw new InternalError("Native ownership but adding potential memory-replacement for '"+returnSizeLookupName+"': "+fieldType.getSignature(null).toString()); + } unit.emitln(" {"); unit.emitln(SetReplaceArrayArgsCheck); unit.emitln(" final ElementBuffer eb = ElementBuffer.allocateDirect("+primElemSizeExpr+", length);"); @@ -1998,6 +2004,9 @@ public class JavaEmitter implements GlueEmitter { } else /* if( !constElemCount && isPointer ) */ { generateSetterSignature(unit, accessMod, false, false, fieldName, fieldType, ownership, containingJTypeName, capitalFieldName, SetArrayArgsPre, baseJElemTypeName+"[]", SetArrayArgsPost, constElemCount, maxOneElement, elemCountExpr, SetArrayApiDocDetail, SetArrayApiDocArgs); + if( Ownership.Native == ownership ) { + throw new InternalError("Native ownership but adding potential memory-replacement for '"+returnSizeLookupName+"': "+fieldType.getSignature(null).toString()); + } unit.emitln(" {"); unit.emitln(SetArrayArgsCheck); unit.emitln(" final int elemCount = "+getElemCountFuncExpr+";"); @@ -2097,6 +2106,9 @@ public class JavaEmitter implements GlueEmitter { // constElemCount/Ownership.Native excluded: SKIP setter for constValue constElemCount Pointer w/ native ownership generateSetterSignature(unit, accessMod, false, false, fieldName, fieldType, ownership, containingJTypeName, capitalFieldName, null, baseJElemTypeName+"[]", SetReplaceArrayArgsPost, constElemCount, maxOneElement, elemCountExpr, SetReplaceArrayApiDocDetail, SetReplaceArrayApiDocArgs); + if( Ownership.Native == ownership ) { + throw new InternalError("Native ownership but adding potential memory-replacement for '"+returnSizeLookupName+"': "+fieldType.getSignature(null).toString()); + } unit.emitln(" {"); unit.emitln(SetReplaceArrayArgsCheck); unit.emitln(" final ElementBuffer eb = ElementBuffer.allocateDirect("+baseJElemTypeName+".size(), length);"); @@ -2129,6 +2141,9 @@ public class JavaEmitter implements GlueEmitter { } else /* if( !constElemCount && isPointer ) */ { generateSetterSignature(unit, accessMod, false, false, fieldName, fieldType, ownership, containingJTypeName, capitalFieldName, SetArrayArgsPre, baseJElemTypeName+"[]", SetArrayArgsPost, constElemCount, maxOneElement, elemCountExpr, SetArrayApiDocDetail, SetArrayApiDocArgs); + if( Ownership.Native == ownership ) { + throw new InternalError("Native ownership but adding potential memory-replacement for '"+returnSizeLookupName+"': "+fieldType.getSignature(null).toString()); + } unit.emitln(" {"); unit.emitln(SetArrayArgsCheck); unit.emitln(" final int elemCount = "+getElemCountFuncExpr+";"); -- cgit v1.2.3