aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-06-29 02:24:58 +0200
committerSven Gothel <[email protected]>2023-06-29 02:24:58 +0200
commita1b107dd3fbe2070a1e667d8d7702912b0af7071 (patch)
tree979efb8c1cf450047b6c806dfc889e8b066859e6 /src
parentce542531f4cb6fe2bf37f3926ea869722e5acf7d (diff)
GlueGen: Move [de]captializeString(..) JavaEmitter -> static in CodeGenUtils
Diffstat (limited to 'src')
-rw-r--r--src/java/com/jogamp/gluegen/CodeGenUtils.java14
-rw-r--r--src/java/com/jogamp/gluegen/JavaEmitter.java14
2 files changed, 21 insertions, 7 deletions
diff --git a/src/java/com/jogamp/gluegen/CodeGenUtils.java b/src/java/com/jogamp/gluegen/CodeGenUtils.java
index 76116f1..5442a24 100644
--- a/src/java/com/jogamp/gluegen/CodeGenUtils.java
+++ b/src/java/com/jogamp/gluegen/CodeGenUtils.java
@@ -44,6 +44,20 @@ import java.util.*;
public class CodeGenUtils {
/**
+ * Converts first letter to upper case.
+ */
+ public static String capitalizeString(final String string) {
+ return Character.toUpperCase(string.charAt(0)) + string.substring(1);
+ }
+
+ /**
+ * Converts first letter to lower case.
+ */
+ public static String decapitalizeString(final String string) {
+ return Character.toLowerCase(string.charAt(0)) + string.substring(1);
+ }
+
+ /**
* Given a java package name (e.g., "java.lang"), return the package as a
* directory path (i.e., "java/lang").
*/
diff --git a/src/java/com/jogamp/gluegen/JavaEmitter.java b/src/java/com/jogamp/gluegen/JavaEmitter.java
index 939ce92..41c5203 100644
--- a/src/java/com/jogamp/gluegen/JavaEmitter.java
+++ b/src/java/com/jogamp/gluegen/JavaEmitter.java
@@ -907,7 +907,7 @@ public class JavaEmitter implements GlueEmitter {
final String fname = nRoot + File.separator + cUnitName;
jniUnit = openCUnit(fname, cUnitName);
// jniUnit.emitHeader(structClassPkgName, containingJTypeName, Collections.emptyList());
- jniUnit.emitHeader(structClassPkgName, containingJTypeName, cfg.customCCode());
+ jniUnit.emitHeader(null, structClassPkgName, containingJTypeName, cfg.customCCode());
} else {
jniUnit = null;
}
@@ -1110,7 +1110,7 @@ public class JavaEmitter implements GlueEmitter {
final FunctionSymbol func = new FunctionSymbol(field.getName(), fieldType.getTargetFunction());
func.rename(renamed); // null is OK
final String javaTypeName = "long";
- final String capFieldName = capitalizeString(fieldName);
+ final String capFieldName = CodeGenUtils.capitalizeString(fieldName);
if( !immutableField && !fieldType.isConst() ) {
// Setter
generateSetterSignature(javaUnit, MethodAccess.PUBLIC, false, false, fieldName, fieldType, Ownership.Parent, containingJTypeName, capFieldName, null, javaTypeName, null, false, false, null, null, null);
@@ -1136,7 +1136,7 @@ public class JavaEmitter implements GlueEmitter {
field + "\" in type \"" + structCTypeName + "\")",
fieldType.getASTLocusTag());
}
- generateGetterSignature(javaUnit, false, false, fieldName, fieldType, Ownership.Parent, fieldType.getName(), capitalizeString(fieldName), null, false, false, null, null);
+ generateGetterSignature(javaUnit, false, false, fieldName, fieldType, Ownership.Parent, fieldType.getName(), CodeGenUtils.capitalizeString(fieldName), null, false, false, null, null);
javaUnit.emitln(" {");
javaUnit.emitln(" return " + fieldType.getName() + ".create( accessor.slice( " +
fieldName+"_offset[mdIdx], "+fieldName+"_size[mdIdx] ) );");
@@ -1165,8 +1165,8 @@ public class JavaEmitter implements GlueEmitter {
} else {
javaTypeName = javaType.getName();
}
- final String capJavaTypeName = capitalizeString(javaTypeName);
- final String capFieldName = capitalizeString(fieldName);
+ final String capJavaTypeName = CodeGenUtils.capitalizeString(javaTypeName);
+ final String capFieldName = CodeGenUtils.capitalizeString(fieldName);
final String sizeDenominator = fieldType.isPointer() ? "pointer" : javaTypeName ;
LOG.log(FINE, structCType.getASTLocusTag(),
@@ -1812,7 +1812,7 @@ public class JavaEmitter implements GlueEmitter {
if( !_constElemCount ) {
// check for const length field
if( elemCountExpr.startsWith("get") && elemCountExpr.endsWith("()") ) {
- final String lenFieldName = decapitalizeString( elemCountExpr.substring(3, elemCountExpr.length()-2) );
+ final String lenFieldName = CodeGenUtils.decapitalizeString( elemCountExpr.substring(3, elemCountExpr.length()-2) );
final Field lenField = structCType.getField(lenFieldName);
if( null != lenField ) {
_constElemCount = lenField.getType().isConst();
@@ -1890,7 +1890,7 @@ public class JavaEmitter implements GlueEmitter {
primElemSizeExpr = null;
}
- final String capitalFieldName = capitalizeString(fieldName);
+ final String capitalFieldName = CodeGenUtils.capitalizeString(fieldName);
final boolean ownElemCountHandling;
final String getElemCountFuncExpr, setElemCountLengthFunc;
if( constElemCount ) {