diff options
Diffstat (limited to 'src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java')
-rw-r--r-- | src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java index ec29b08..b812416 100644 --- a/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java +++ b/src/java/com/jogamp/gluegen/procaddress/ProcAddressEmitter.java @@ -1,6 +1,6 @@ /* + * Copyright (c) 2010-2023 JogAmp Community. All rights reserved. * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2013 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 @@ -40,7 +40,6 @@ package com.jogamp.gluegen.procaddress; import java.io.File; -import java.io.PrintWriter; import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashSet; @@ -52,6 +51,7 @@ import java.util.logging.Level; import com.jogamp.gluegen.CMethodBindingEmitter; import com.jogamp.gluegen.CodeGenUtils; import com.jogamp.gluegen.FunctionEmitter; +import com.jogamp.gluegen.JavaCodeUnit; import com.jogamp.gluegen.JavaConfiguration; import com.jogamp.gluegen.JavaEmitter; import com.jogamp.gluegen.JavaMethodBindingEmitter; @@ -72,7 +72,7 @@ public class ProcAddressEmitter extends JavaEmitter { public static final String PROCADDRESS_VAR_PREFIX = "_addressof_"; protected static final String WRAP_PREFIX = "dispatch_"; private TypeDictionary typedefDictionary; - protected PrintWriter tableWriter; + protected JavaCodeUnit tableJavaUnit; protected Set<String> emittedTableEntries; protected String tableClassPackage; protected String tableClassName; @@ -307,47 +307,47 @@ public class ProcAddressEmitter extends JavaEmitter { final String jImplRoot = getJavaOutputDir() + File.separator + CodeGenUtils.packageAsPath(implPackageName); - tableWriter = openFile(jImplRoot + File.separator + tableClassName + ".java", tableClassName); - emittedTableEntries = new HashSet<String>(); + final String javaFileName = jImplRoot + File.separator + tableClassName + ".java"; + tableJavaUnit = openJavaUnit(javaFileName, implPackageName, tableClassName); - CodeGenUtils.emitAutogeneratedWarning(tableWriter, this); + emittedTableEntries = new HashSet<String>(); - tableWriter.println("package " + implPackageName + ";"); - tableWriter.println(); + tableJavaUnit.emitln("package " + implPackageName + ";"); + tableJavaUnit.emitln(); for (final String imporT : getConfig().imports()) { - tableWriter.println("import " + imporT + ";"); + tableJavaUnit.emitln("import " + imporT + ";"); } - tableWriter.println("import " + ProcAddressTable.class.getName() + ";"); - tableWriter.println("import com.jogamp.common.util.SecurityUtil;"); - tableWriter.println(); - - tableWriter.println("/**"); - tableWriter.println(" * This table is a cache of pointers to the dynamically-linkable C library."); - tableWriter.println(" * @see " + ProcAddressTable.class.getSimpleName()); - tableWriter.println(" */"); + tableJavaUnit.emitln("import " + ProcAddressTable.class.getName() + ";"); + tableJavaUnit.emitln("import com.jogamp.common.util.SecurityUtil;"); + tableJavaUnit.emitln(); + + tableJavaUnit.emitln("/**"); + tableJavaUnit.emitln(" * This table is a cache of pointers to the dynamically-linkable C library."); + tableJavaUnit.emitln(" * @see " + ProcAddressTable.class.getSimpleName()); + tableJavaUnit.emitln(" */"); for (int i = 0; accessModifiers != null && i < accessModifiers.length; ++i) { - tableWriter.print(accessModifiers[i]); - tableWriter.print(' '); + tableJavaUnit.emit(accessModifiers[i]); + tableJavaUnit.emit(" "); } - tableWriter.println("final class " + tableClassName + " extends "+ ProcAddressTable.class.getSimpleName() + " {"); - tableWriter.println(); + tableJavaUnit.emitln("final class " + tableClassName + " extends "+ ProcAddressTable.class.getSimpleName() + " {"); + tableJavaUnit.emitln(); for (final String string : getProcAddressConfig().getForceProcAddressGen()) { emitProcAddressTableEntryForString(string); } - tableWriter.println(); - tableWriter.println(" public "+tableClassName+"(){ super(); }"); - tableWriter.println(); - tableWriter.println(" public "+tableClassName+"("+FunctionAddressResolver.class.getName()+" resolver){ super(resolver); }"); - tableWriter.println(); + tableJavaUnit.emitln(); + tableJavaUnit.emitln(" public "+tableClassName+"(){ super(); }"); + tableJavaUnit.emitln(); + tableJavaUnit.emitln(" public "+tableClassName+"("+FunctionAddressResolver.class.getName()+" resolver){ super(resolver); }"); + tableJavaUnit.emitln(); } protected void endProcAddressTable() throws Exception { - tableWriter.println("} // end of class " + tableClassName); - tableWriter.flush(); - tableWriter.close(); + tableJavaUnit.emitln("} // end of class " + tableClassName); + tableJavaUnit.close(); + tableJavaUnit = null; } protected void emitProcAddressTableEntryForString(final String str) { @@ -357,10 +357,10 @@ public class ProcAddressEmitter extends JavaEmitter { return; } emittedTableEntries.add(str); - tableWriter.print(" /* pp */ long "); - tableWriter.print(PROCADDRESS_VAR_PREFIX); - tableWriter.print(str); - tableWriter.println(";"); + tableJavaUnit.emit(" /* pp */ long "); + tableJavaUnit.emit(PROCADDRESS_VAR_PREFIX); + tableJavaUnit.emit(str); + tableJavaUnit.emitln(";"); } protected ProcAddressConfiguration getProcAddressConfig() { |