JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
GLJavaMethodBindingEmitter.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * Copyright (c) 2010 JogAmp Community. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * - Redistribution of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistribution in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of Sun Microsystems, Inc. or the names of
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * This software is provided "AS IS," without a warranty of any kind. ALL
21 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
22 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
23 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
24 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
25 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
26 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
27 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
28 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
29 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
30 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
31 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 *
33 * You acknowledge that this software is not designed or intended for use
34 * in the design, construction, operation or maintenance of any nuclear
35 * facility.
36 *
37 * Sun gratefully acknowledges that this software was originally authored
38 * and developed by Kenneth Bradley Russell and Christopher John Kline.
39 */
40package com.jogamp.gluegen.opengl;
41
42import com.jogamp.gluegen.CommentEmitter;
43import com.jogamp.gluegen.GlueGenException;
44import com.jogamp.gluegen.JavaEmitter;
45import com.jogamp.gluegen.JavaMethodBindingEmitter;
46import com.jogamp.gluegen.MethodBinding;
47import com.jogamp.gluegen.cgram.types.FunctionSymbol;
48import com.jogamp.gluegen.cgram.types.Type;
49import com.jogamp.gluegen.procaddress.ProcAddressJavaMethodBindingEmitter;
50
51import java.io.PrintWriter;
52
53/** A specialization of the proc address emitter which knows how to
54change argument names to take into account Vertex Buffer Object /
55Pixel Buffer Object variants. */
56public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmitter {
57
58 protected boolean bufferObjectVariant;
60 protected CommentEmitter glCommentEmitter = new GLCommentEmitter();
61
62 public GLJavaMethodBindingEmitter(final JavaMethodBindingEmitter methodToWrap, final boolean callThroughProcAddress,
63 final String getProcAddressTableExpr, final boolean changeNameAndArguments, final boolean bufferObjectVariant, final GLEmitter emitter) {
64
65 super(methodToWrap, callThroughProcAddress, getProcAddressTableExpr, changeNameAndArguments, emitter);
66 this.bufferObjectVariant = bufferObjectVariant;
67 this.glEmitter = emitter;
68 setCommentEmitter(glCommentEmitter);
69 }
70
71 public GLJavaMethodBindingEmitter(final ProcAddressJavaMethodBindingEmitter methodToWrap, final GLEmitter emitter, final boolean bufferObjectVariant) {
72 super(methodToWrap);
73 this.bufferObjectVariant = bufferObjectVariant;
74 this.glEmitter = emitter;
75 setCommentEmitter(glCommentEmitter);
76 }
77
79 this(methodToWrap, methodToWrap.glEmitter, methodToWrap.bufferObjectVariant);
80 }
81
82 @Override
83 protected String getArgumentName(final int i) {
84 final String name = super.getArgumentName(i);
85
87 return name;
88 }
89
90 // Emitters for VBO/PBO-related routines change the outgoing
91 // argument name for the buffer
92 if (binding.getJavaArgumentType(i).isLong()) {
93 final Type cType = binding.getCArgumentType(i);
94 final Type targetType = cType.asPointer().getTargetType();
95 if (cType.isPointer() && (targetType.isVoid() || targetType.isPrimitive())) {
96 return name + "_buffer_offset";
97 }
98 }
99
100 return name;
101 }
102
103 protected class GLCommentEmitter extends JavaMethodBindingEmitter.DefaultCommentEmitter {
104
105 @Override
106 protected void emitBindingCSignature(final MethodBinding binding, final PrintWriter writer) {
107 final String symbolRenamed = binding.getName();
108 final StringBuilder newComment = new StringBuilder();
109
110 final FunctionSymbol funcSym = binding.getCSymbol();
111 writer.print("<code> ");
112 writer.print(funcSym.getType().toString(symbolRenamed, tagNativeBinding));
113 writer.print(" </code> ");
114
115 newComment.append("<br>Part of ");
116 if (0 == glEmitter.addExtensionsOfSymbols2Doc(newComment, ", ", ", ", symbolRenamed)) {
118 newComment.append("CORE FUNC");
119 } else {
120 if( !((GLConfiguration)cfg).dropDocInfo ) {
121 final GlueGenException ex = new GlueGenException("Couldn't find extension to: " + funcSym.getAliasedString(), funcSym.getASTLocusTag());
122 System.err.println(ex.getMessage());
124 // glEmitter.getGLConfig().dumpRenames();
125 throw ex;
126 } else {
127 newComment.append("UNDEFINED");
128 }
129 }
130 }
131 newComment.append("<br>");
132 emitAliasedDocNamesComment(funcSym, newComment);
133 writer.print(newComment.toString());
134 }
135 }
136}
BuildStaticGLInfo getGLDocInfo()
Returns the information about the association between #defines, function symbols and the OpenGL exten...
boolean getAllowNonGLExtensions()
If true, accept all non encapsulated defines and functions, as it is mandatory for GL declarations.
A subclass of ProcAddressEmitter with special OpenGL-specific configuration abilities.
Definition: GLEmitter.java:74
int addExtensionsOfSymbols2Doc(StringBuilder buf, final String sep1, final String sep2, final String first)
Definition: GLEmitter.java:457
void emitBindingCSignature(final MethodBinding binding, final PrintWriter writer)
A specialization of the proc address emitter which knows how to change argument names to take into ac...
GLJavaMethodBindingEmitter(final GLJavaMethodBindingEmitter methodToWrap)
GLJavaMethodBindingEmitter(final JavaMethodBindingEmitter methodToWrap, final boolean callThroughProcAddress, final String getProcAddressTableExpr, final boolean changeNameAndArguments, final boolean bufferObjectVariant, final GLEmitter emitter)
GLJavaMethodBindingEmitter(final ProcAddressJavaMethodBindingEmitter methodToWrap, final GLEmitter emitter, final boolean bufferObjectVariant)