2010-09-26 19:43:24 -04:00
/ *
* Copyright ( c ) 2002 - 2008 LWJGL Project
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions are
* met :
*
* * Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
*
* * 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 .
*
* * Neither the name of ' LWJGL ' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* " 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 THE COPYRIGHT OWNER 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 .
* /
package org.lwjgl.util.generator.opengl ;
2014-09-14 10:16:51 -04:00
import org.lwjgl.util.generator.* ;
2010-09-26 19:43:24 -04:00
import java.io.PrintWriter ;
import java.util.Arrays ;
import java.util.EnumSet ;
import java.util.Iterator ;
2014-09-14 10:07:56 -04:00
import java.util.List ;
2022-08-16 14:27:14 -04:00
import javax.annotation.processing.* ;
2014-09-14 10:07:56 -04:00
import javax.lang.model.element.ExecutableElement ;
import javax.lang.model.element.TypeElement ;
import javax.lang.model.type.TypeMirror ;
2010-09-26 19:43:24 -04:00
/ * *
* Generator visitor for the context capabilities generator tool
*
* @author elias_naur < elias_naur @users.sourceforge.net >
* @version $Revision : 3355 $
* $Id : ContextCapabilitiesGenerator . java 3355 2010 - 05 - 27 22 : 56 : 29Z spasi $
* /
2022-09-12 20:44:41 -04:00
public final class GLCapabilitiesGenerator {
2010-09-26 19:43:24 -04:00
2014-09-14 10:16:51 -04:00
private static final String STUBS_LOADED_NAME = " loaded_stubs " ;
private static final String ALL_INIT_METHOD_NAME = " initAllStubs " ;
2010-09-26 19:43:24 -04:00
private static final String POINTER_INITIALIZER_POSTFIX = " _initNativeFunctionAddresses " ;
2014-09-14 10:16:51 -04:00
private static final String CACHED_EXTS_VAR_NAME = " supported_extensions " ;
private static final String PROFILE_MASK_VAR_NAME = " profileMask " ;
private static final String EXTENSION_PREFIX = " GL_ " ;
private static final String CORE_PREFIX = " Open " ;
2010-09-26 19:43:24 -04:00
public static void generateClassPrologue ( PrintWriter writer , boolean context_specific , boolean generate_error_checks ) {
2022-09-12 20:44:41 -04:00
writer . append ( " public final class " + Utils . CONTEXT_CAPS_CLASS_NAME + " { \ n " ) ;
2022-09-08 07:10:40 -04:00
writer . append ( " \ tstatic final boolean DEBUG = " ) . append ( Boolean . toString ( generate_error_checks ) ) . append ( " ; \ n " ) ;
writer . append ( " \ tfinal APIUtil util = new APIUtil(); \ n " ) ;
writer . append ( " \ tfinal StateTracker tracker = new StateTracker(); \ n \ n " ) ;
2010-09-26 19:43:24 -04:00
if ( ! context_specific ) {
2022-09-08 07:10:40 -04:00
writer . append ( " \ tprivate static boolean " + STUBS_LOADED_NAME + " = false; \ n " ) ;
2010-09-26 19:43:24 -04:00
}
}
public static void generateInitializerPrologue ( PrintWriter writer ) {
2022-09-08 07:10:40 -04:00
writer . append ( " \ t " + Utils . CONTEXT_CAPS_CLASS_NAME + " (boolean forwardCompatible) throws LWJGLException { \ n " ) ;
writer . append ( " \ t \ tSet<String> " + CACHED_EXTS_VAR_NAME + " = " + ALL_INIT_METHOD_NAME + " (forwardCompatible); \ n " ) ;
2010-09-26 19:43:24 -04:00
}
2022-09-12 20:44:41 -04:00
private static PrintWriter translateFieldName ( PrintWriter writer , String interface_name ) {
return writer . append ( interface_name . startsWith ( " GL " ) ? CORE_PREFIX : EXTENSION_PREFIX )
. append ( interface_name ) ;
2010-09-26 19:43:24 -04:00
}
2014-09-14 10:07:56 -04:00
public static void generateSuperClassAdds ( PrintWriter writer , TypeElement d , ProcessingEnvironment env ) {
List < ? extends TypeMirror > super_interfaces = d . getInterfaces ( ) ;
2010-09-26 19:43:24 -04:00
if ( super_interfaces . size ( ) > 1 )
throw new RuntimeException ( d + " extends more than one other interface " ) ;
if ( super_interfaces . size ( ) = = 1 ) {
2014-09-14 10:07:56 -04:00
TypeMirror super_interface = super_interfaces . iterator ( ) . next ( ) ;
2022-09-12 20:44:41 -04:00
writer . append ( " \ t \ tif ( " + CACHED_EXTS_VAR_NAME + " .contains( \" " ) ;
translateFieldName ( writer , d . getSimpleName ( ) . toString ( ) ) . append ( " \" )) \ n " + " \ t \ t \ t " ) ;
2014-09-14 10:07:56 -04:00
generateAddExtension ( writer , env . getElementUtils ( ) . getTypeElement ( super_interface . toString ( ) ) ) ;
2010-09-26 19:43:24 -04:00
}
}
2014-09-14 10:07:56 -04:00
public static void generateInitializer ( PrintWriter writer , TypeElement d , ProcessingEnvironment env ) {
2022-09-12 20:44:41 -04:00
String non_translated_field_name = d . getSimpleName ( ) . toString ( ) ;
translateFieldName ( writer . append ( " \ t \ tthis. " ) , non_translated_field_name ) . append ( " = " ) ;
2022-09-08 07:10:40 -04:00
writer . append ( CACHED_EXTS_VAR_NAME + " .contains( \" " ) ;
2022-09-12 20:44:41 -04:00
translateFieldName ( writer , non_translated_field_name ) . append ( " \" ) " ) ;
2014-09-14 10:07:56 -04:00
List < ? extends TypeMirror > super_interfaces = d . getInterfaces ( ) ;
2014-09-14 10:16:51 -04:00
if ( super_interfaces . size ( ) > 1 )
2010-09-26 19:43:24 -04:00
throw new RuntimeException ( d + " extends more than one other interface " ) ;
if ( super_interfaces . size ( ) = = 1 ) {
2014-09-14 10:07:56 -04:00
TypeMirror super_interface = super_interfaces . iterator ( ) . next ( ) ;
2022-09-12 20:44:41 -04:00
writer . append ( " \ n \ t \ t \ t&& " + CACHED_EXTS_VAR_NAME + " .contains( \" " ) ;
translateFieldName ( writer , env . getElementUtils ( ) . getTypeElement ( super_interface . toString ( ) ) . getSimpleName ( ) . toString ( ) ) . append ( " \" ) " ) ;
2010-09-26 19:43:24 -04:00
}
Alias alias_annotation = d . getAnnotation ( Alias . class ) ;
if ( alias_annotation ! = null ) {
2022-09-12 20:44:41 -04:00
writer . append ( " \ n \ t \ t \ t|| " + CACHED_EXTS_VAR_NAME + " .contains( \" " ) ;
translateFieldName ( writer , alias_annotation . value ( ) ) . append ( " \" ) " ) ;
2010-09-26 19:43:24 -04:00
}
2022-09-08 07:10:40 -04:00
writer . append ( " ; \ n " ) ;
2010-09-26 19:43:24 -04:00
}
2022-09-12 20:44:41 -04:00
private static PrintWriter getAddressesInitializerName ( PrintWriter writer , String class_name ) {
return writer . append ( class_name ) . append ( POINTER_INITIALIZER_POSTFIX ) ;
2010-09-26 19:43:24 -04:00
}
public static void generateInitStubsPrologue ( PrintWriter writer , boolean context_specific ) {
2022-09-12 20:44:41 -04:00
writer . append ( " \ tprivate Set<String> " + ALL_INIT_METHOD_NAME + " (boolean forwardCompatible) throws LWJGLException { \ n " ) ;
2010-09-26 19:43:24 -04:00
// Load the basic pointers we need to detect OpenGL version and supported extensions.
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ tglGetError = GLContext.getFunctionAddress( \" glGetError \" ); \ n " ) ;
writer . append ( " \ t \ tglGetString = GLContext.getFunctionAddress( \" glGetString \" ); \ n " ) ;
2010-09-26 19:43:24 -04:00
// Initialize GL11.glGetIntegerv and GL30.glGetStringi here, in case we have created an OpenGL 3.0 context.
// (they will be used in GLContext.getSupportedExtensions)
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ tglGetIntegerv = GLContext.getFunctionAddress( \" glGetIntegerv \" ); \ n " ) ;
writer . append ( " \ t \ tglGetStringi = GLContext.getFunctionAddress( \" glGetStringi \" ); \ n " ) ;
2010-09-26 19:43:24 -04:00
// Get the supported extensions set.
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ tGLContext.setCapabilities(this); \ n " ) ;
writer . append ( " \ t \ tSet<String> " + CACHED_EXTS_VAR_NAME + " = new HashSet<String>(256); \ n " ) ;
writer . append ( " \ t \ tint " + PROFILE_MASK_VAR_NAME + " = GLContext.getSupportedExtensions( " + CACHED_EXTS_VAR_NAME + " ); \ n " ) ;
2010-09-26 19:43:24 -04:00
// Force forward compatible mode when OpenGL version is 3.1 or higher and ARB_compatibility is not available.
2022-09-12 20:44:41 -04:00
writer . append ( " \ t \ tif ( " + CACHED_EXTS_VAR_NAME + " .contains( \" OpenGL31 \" ) && !( " + CACHED_EXTS_VAR_NAME + " .contains( \" GL_ARB_compatibility \" ) || ( " + PROFILE_MASK_VAR_NAME + " & GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) != 0)) { \ n " ) ;
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ t \ tforwardCompatible = true; \ n " ) ;
2022-09-12 20:44:41 -04:00
writer . append ( " \ t \ t \ tLWJGLUtil.logger().log(() -> \" Forcing forwardCompatible=true because OpenGL version is 3.1 or higher AND ARB_compatibility is not available OR " + PROFILE_MASK_VAR_NAME + " has GL32.GL_CONTEXT_COMPATIBILITY_PROFILE_BIT set. \" ); \ n " ) ;
writer . append ( " \ t \ t} \ n " ) ;
2010-09-26 19:43:24 -04:00
if ( ! context_specific ) {
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ tif ( " + STUBS_LOADED_NAME + " ) \ n " ) ;
writer . append ( " \ t \ t \ treturn GLContext.getSupportedExtensions(); \ n " ) ;
writer . append ( " \ t \ torg.lwjgl.opengl.GL11. " + Utils . STUB_INITIALIZER_NAME + " (); \ n " ) ;
2010-09-26 19:43:24 -04:00
} else {
2022-09-12 20:44:41 -04:00
writer . append ( " \ t \ tif (! " ) ;
getAddressesInitializerName ( writer , " GL11 " ) . append ( " (forwardCompatible)) \ n " + " \ t \ t \ tthrow new LWJGLException( \" GL11 not supported \" ); \ n " ) ;
2010-09-26 19:43:24 -04:00
}
}
public static void generateInitStubsEpilogue ( PrintWriter writer , boolean context_specific ) {
if ( ! context_specific ) {
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ t " + STUBS_LOADED_NAME + " = true; \ n " ) ;
2010-09-26 19:43:24 -04:00
}
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ treturn " + CACHED_EXTS_VAR_NAME + " ; \ n " ) ;
writer . append ( " \ t} \ n " ) ;
2010-09-26 19:43:24 -04:00
}
2014-09-14 10:07:56 -04:00
public static void generateUnloadStubs ( ProcessingEnvironment env , PrintWriter writer , TypeElement d ) {
2014-09-14 10:16:51 -04:00
if ( Utils . getMethods ( d ) . size ( ) > 0 ) {
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ tGLContext.resetNativeStubs( " ) . append ( Utils . getSimpleClassName ( d ) ) . append ( " .class); \ n " ) ;
2010-09-26 19:43:24 -04:00
}
}
2014-09-14 10:07:56 -04:00
public static void generateInitStubs ( ProcessingEnvironment env , PrintWriter writer , TypeElement d , boolean context_specific ) {
2014-09-14 10:16:51 -04:00
if ( Utils . getMethods ( d ) . size ( ) > 0 ) {
2010-09-26 19:43:24 -04:00
if ( context_specific ) {
final Alias alias_annotation = d . getAnnotation ( Alias . class ) ;
2022-09-12 20:44:41 -04:00
if ( d . getAnnotation ( ForceInit . class ) ! = null ) {
writer . append ( " \ t \ t " + CACHED_EXTS_VAR_NAME + " .add( \" " ) ;
translateFieldName ( writer , d . getSimpleName ( ) . toString ( ) ) . append ( " \" ); \ n " ) ;
}
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ tif ( " ) ;
2022-09-12 20:44:41 -04:00
if ( alias_annotation ! = null ) {
2022-09-08 07:10:40 -04:00
writer . append ( '(' ) ;
2022-09-12 20:44:41 -04:00
}
2022-09-08 07:10:40 -04:00
writer . append ( CACHED_EXTS_VAR_NAME + " .contains( \" " ) ;
2022-09-12 20:44:41 -04:00
translateFieldName ( writer , d . getSimpleName ( ) . toString ( ) ) . append ( " \" ) " ) ;
2010-09-26 19:43:24 -04:00
if ( alias_annotation ! = null ) {
2022-09-08 07:10:40 -04:00
writer . append ( " || " + CACHED_EXTS_VAR_NAME + " .contains( \" " ) ;
2022-09-12 20:44:41 -04:00
translateFieldName ( writer , alias_annotation . value ( ) ) . append ( " \" )) " ) ;
2010-09-26 19:43:24 -04:00
}
2022-09-12 20:44:41 -04:00
writer . append ( " && ! " ) ;
getAddressesInitializerName ( writer , d . getSimpleName ( ) . toString ( ) ) . append ( '(' ) ;
if ( d . getAnnotation ( DeprecatedGL . class ) ! = null ) {
2022-09-08 07:10:40 -04:00
writer . append ( " forwardCompatible " ) ;
2022-09-12 20:44:41 -04:00
}
2010-09-26 19:43:24 -04:00
if ( d . getAnnotation ( Dependent . class ) ! = null ) {
2022-09-12 20:44:41 -04:00
if ( d . getAnnotation ( DeprecatedGL . class ) ! = null ) {
2022-09-08 07:10:40 -04:00
writer . append ( " , " ) ;
2022-09-12 20:44:41 -04:00
}
writer . append ( CACHED_EXTS_VAR_NAME ) ;
2010-09-26 19:43:24 -04:00
}
if ( alias_annotation ! = null ) {
2022-09-12 20:44:41 -04:00
writer . append ( " )) { \ n " + " \ t \ t \ tremove( " + CACHED_EXTS_VAR_NAME + " , \" " ) ;
translateFieldName ( writer , alias_annotation . value ( ) ) . append ( " \" ); \ n " ) ;
} else {
2022-09-08 07:10:40 -04:00
writer . append ( " )) \ n " ) ;
2022-09-12 20:44:41 -04:00
}
writer . append ( " \ t \ t \ tremove( " + CACHED_EXTS_VAR_NAME + " , \" " ) ;
translateFieldName ( writer , d . getSimpleName ( ) . toString ( ) ) . append ( " \" ); \ n " ) ;
if ( alias_annotation ! = null ) {
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ t} \ n " ) ;
2022-09-12 20:44:41 -04:00
}
2010-09-26 19:43:24 -04:00
} else {
2022-09-12 20:44:41 -04:00
writer . append ( " \ t \ tGLContext. " + Utils . STUB_INITIALIZER_NAME + '(' ) . append ( Utils . getSimpleClassName ( d ) ) ;
writer . append ( " .class, " + CACHED_EXTS_VAR_NAME + " , \" " ) ;
translateFieldName ( writer , d . getSimpleName ( ) . toString ( ) ) . append ( " \" ); \ n " ) ;
2010-09-26 19:43:24 -04:00
}
}
}
2014-09-14 10:07:56 -04:00
private static void generateAddExtension ( PrintWriter writer , TypeElement d ) {
2022-09-12 20:44:41 -04:00
writer . append ( CACHED_EXTS_VAR_NAME + " .add( \" " ) ;
translateFieldName ( writer , d . getSimpleName ( ) . toString ( ) ) . append ( " \" ); \ n " ) ;
2010-09-26 19:43:24 -04:00
}
2014-09-14 10:07:56 -04:00
public static void generateAddressesInitializers ( ProcessingEnvironment env , PrintWriter writer , TypeElement d ) {
2014-09-14 10:16:51 -04:00
Iterator < ? extends ExecutableElement > methods = Utils . getMethods ( d ) . iterator ( ) ;
2022-09-12 20:44:41 -04:00
if ( ! methods . hasNext ( ) ) return ;
2010-09-26 19:43:24 -04:00
2022-09-12 20:44:41 -04:00
writer . append ( " \ tprivate boolean " ) ;
getAddressesInitializerName ( writer , d . getSimpleName ( ) . toString ( ) ) . append ( '(' ) ;
2010-09-26 19:43:24 -04:00
boolean optional ;
boolean deprecated = d . getAnnotation ( DeprecatedGL . class ) ! = null ;
Dependent dependent = d . getAnnotation ( Dependent . class ) ;
2022-09-12 20:44:41 -04:00
if ( deprecated ) {
2022-09-08 07:10:40 -04:00
writer . append ( " boolean forwardCompatible " ) ;
2022-09-12 20:44:41 -04:00
}
if ( dependent ! = null ) {
if ( deprecated ) {
2022-09-08 07:10:40 -04:00
writer . append ( ',' ) ;
2022-09-12 20:44:41 -04:00
}
writer . append ( " Set<String> " + CACHED_EXTS_VAR_NAME ) ;
2010-09-26 19:43:24 -04:00
}
Alias alias_annotation = d . getAnnotation ( Alias . class ) ;
boolean aliased = alias_annotation ! = null & & alias_annotation . postfix ( ) . length ( ) > 0 ;
2022-09-12 20:44:41 -04:00
writer . append ( " ) { \ n " + " \ t \ treturn \ n " ) ;
2010-09-26 19:43:24 -04:00
boolean first = true ;
while ( methods . hasNext ( ) ) {
2014-09-14 10:07:56 -04:00
ExecutableElement method = methods . next ( ) ;
2010-09-26 19:43:24 -04:00
if ( method . getAnnotation ( Alternate . class ) ! = null )
continue ;
2022-09-12 20:44:41 -04:00
if ( ! first ) {
2022-09-08 07:10:40 -04:00
writer . append ( " & \ n " ) ;
2022-09-12 20:44:41 -04:00
} else {
2010-09-26 19:43:24 -04:00
first = false ;
2022-09-12 20:44:41 -04:00
}
2010-09-26 19:43:24 -04:00
optional = method . getAnnotation ( Optional . class ) ! = null ;
deprecated = method . getAnnotation ( DeprecatedGL . class ) ! = null ;
dependent = method . getAnnotation ( Dependent . class ) ;
2022-09-08 07:10:40 -04:00
writer . append ( " \ t \ t \ t( " ) ;
2022-09-12 20:44:41 -04:00
if ( optional ) {
2022-09-08 07:10:40 -04:00
writer . append ( '(' ) ;
2022-09-12 20:44:41 -04:00
}
if ( deprecated ) {
2022-09-08 07:10:40 -04:00
writer . append ( " forwardCompatible || " ) ;
2022-09-12 20:44:41 -04:00
}
if ( dependent ! = null ) {
if ( dependent . value ( ) . indexOf ( ',' ) = = - 1 )
writer . append ( " ! " + CACHED_EXTS_VAR_NAME + " .contains( \" " ) . append ( dependent . value ( ) ) . append ( " \" ) || " ) ;
2010-09-26 19:43:24 -04:00
else {
2022-09-08 07:10:40 -04:00
writer . append ( " !(false " ) ;
2022-09-12 20:44:41 -04:00
for ( String extension : dependent . value ( ) . split ( " , " ) ) {
writer . append ( " || " + CACHED_EXTS_VAR_NAME + " .contains( \" " ) . append ( extension ) . append ( " \" ) " ) ;
}
2022-09-08 07:10:40 -04:00
writer . append ( " ) || " ) ;
2010-09-26 19:43:24 -04:00
}
}
2022-09-12 20:44:41 -04:00
if ( deprecated | | dependent ! = null ) {
2022-09-08 07:10:40 -04:00
writer . append ( '(' ) ;
2022-09-12 20:44:41 -04:00
}
2022-09-08 07:10:40 -04:00
writer . append ( Utils . getFunctionAddressName ( d , method ) ) . append ( " = " ) ;
2010-09-26 19:43:24 -04:00
PlatformDependent platform_dependent = method . getAnnotation ( PlatformDependent . class ) ;
2022-09-12 20:44:41 -04:00
if ( platform_dependent ! = null ) {
2010-09-26 19:43:24 -04:00
EnumSet < Platform > platform_set = EnumSet . copyOf ( Arrays . asList ( platform_dependent . value ( ) ) ) ;
2022-09-12 20:44:41 -04:00
writer . append ( " GLContext.getPlatformSpecificFunctionAddress( \" " ) . append ( Platform . ALL . getPrefix ( ) ) . append ( " \" , " + " new String[]{ " ) ;
2010-09-26 19:43:24 -04:00
Iterator < Platform > platforms = platform_set . iterator ( ) ;
while ( platforms . hasNext ( ) ) {
2022-09-08 07:10:40 -04:00
writer . append ( " \" " ) . append ( platforms . next ( ) . getOSPrefix ( ) ) . append ( " \" " ) ;
2022-09-12 20:44:41 -04:00
if ( platforms . hasNext ( ) ) {
2022-09-08 07:10:40 -04:00
writer . append ( " , " ) ;
2022-09-12 20:44:41 -04:00
}
2010-09-26 19:43:24 -04:00
}
2022-09-08 07:10:40 -04:00
writer . append ( " }, new String[]{ " ) ;
2010-09-26 19:43:24 -04:00
platforms = platform_set . iterator ( ) ;
2022-09-12 20:44:41 -04:00
while ( platforms . hasNext ( ) ) {
2022-09-08 07:10:40 -04:00
writer . append ( " \" " ) . append ( platforms . next ( ) . getPrefix ( ) ) . append ( " \" " ) ;
2022-09-12 20:44:41 -04:00
if ( platforms . hasNext ( ) ) {
2022-09-08 07:10:40 -04:00
writer . append ( " , " ) ;
2022-09-12 20:44:41 -04:00
}
2010-09-26 19:43:24 -04:00
}
2022-09-08 07:10:40 -04:00
writer . append ( " }, " ) ;
2022-09-12 20:44:41 -04:00
} else if ( aliased ) {
2022-09-08 07:10:40 -04:00
writer . append ( " GLContext.getFunctionAddress(new String[] { \" " ) . append ( method . getSimpleName ( ) ) . append ( " \" , \" " ) . append ( method . getSimpleName ( ) ) . append ( alias_annotation . postfix ( ) ) . append ( " \" })) != 0 " ) ;
2022-09-12 20:44:41 -04:00
} else {
2022-09-08 07:10:40 -04:00
writer . append ( " GLContext.getFunctionAddress( " ) ;
2022-09-12 20:44:41 -04:00
}
if ( ! aliased ) {
2022-09-08 07:10:40 -04:00
writer . append ( " \" " ) . append ( method . getSimpleName ( ) ) . append ( " \" )) != 0 " ) ;
2022-09-12 20:44:41 -04:00
}
if ( deprecated | | dependent ! = null ) {
2022-09-08 07:10:40 -04:00
writer . append ( ')' ) ;
2022-09-12 20:44:41 -04:00
}
if ( optional ) {
2022-09-08 07:10:40 -04:00
writer . append ( " || true) " ) ;
2022-09-12 20:44:41 -04:00
}
2010-09-26 19:43:24 -04:00
}
2022-09-12 20:44:41 -04:00
writer . append ( " ; \ n " + " \ t} \ n " ) ;
2010-09-26 19:43:24 -04:00
}
2014-09-14 10:07:56 -04:00
public static void generateSymbolAddresses ( ProcessingEnvironment env , PrintWriter writer , TypeElement d ) {
2010-09-26 19:43:24 -04:00
boolean first = true ;
2022-09-12 20:44:41 -04:00
for ( final ExecutableElement method : Utils . getMethods ( d ) ) {
if ( method . getAnnotation ( Alternate . class ) ! = null | | method . getAnnotation ( Reuse . class ) ! = null ) continue ;
2010-09-28 17:11:35 -04:00
2022-09-12 20:44:41 -04:00
if ( first ) {
2022-09-08 07:10:40 -04:00
writer . append ( " \ t// " ) . append ( d . getSimpleName ( ) ) . append ( '\n' ) ;
2010-09-26 19:43:24 -04:00
first = false ;
}
2022-09-08 07:10:40 -04:00
writer . append ( " \ tlong " ) . append ( Utils . getFunctionAddressName ( d , method ) ) . append ( " ; \ n " ) ;
2010-09-26 19:43:24 -04:00
}
}
2014-09-14 10:07:56 -04:00
public static void generateField ( PrintWriter writer , TypeElement d ) {
2022-09-12 20:44:41 -04:00
writer . append ( " \ tpublic final boolean " ) ;
translateFieldName ( writer , d . getSimpleName ( ) . toString ( ) ) . append ( " ; \ n " ) ;
2010-09-26 19:43:24 -04:00
}
2022-08-16 14:27:14 -04:00
}