GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
JavaCallbackEmitter.java
Go to the documentation of this file.
1/**
2 * Copyright 2023 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.gluegen;
29
30import com.jogamp.gluegen.JavaConfiguration.JavaCallbackInfo;
31import com.jogamp.gluegen.cgram.types.Type;
32
33import java.nio.ByteBuffer;
34
35public final class JavaCallbackEmitter {
36 final JavaConfiguration cfg;
37 final MethodBinding binding;
38 final String setFuncSignature;
39 final JavaCallbackInfo info;
40 final String capIfaceName;
41 final String lowIfaceName;
42 final String lockInstanceName;
43 final String dataMapInstanceName;
44 final String dataInstanceName;
45 final String DataClassName;
46 final String fqUsrParamClassName;
47 final JavaType cbFuncJavaReturnType;
48 final String jcbNextIDVarName;
49
50 final boolean userParamDefined;
51
52 final String setFuncCBArgName;
53 final Type setFuncUserParamCType;
54 final JavaType setFuncUserParamJType;
55 final String setFuncUserParamTypeName;
56 final String setFuncUserParamArgName;
57 final boolean userParamIsKey;
58 final boolean userParamIsCompound;
59 final boolean userParamIsMappedToID;
60 final String userParamIDMapInstanceName;
61
62 final String userParamClassName;
63 final boolean customKeyClass;
64 final String KeyClassName;
65 final boolean useDataMap;
66
67 public JavaCallbackEmitter(final JavaConfiguration cfg, final MethodBinding mb, final JavaCallbackInfo javaCallback, final String setFuncSignature) {
68 this.cfg = cfg;
69 this.binding = mb;
70 this.setFuncSignature = setFuncSignature;
71 this.info = javaCallback;
72
73 capIfaceName = CodeGenUtils.capitalizeString( mb.getInterfaceName() );
75 lockInstanceName = lowIfaceName+"Lock";
76 dataMapInstanceName = lowIfaceName+"DataMap";
77 dataInstanceName = lowIfaceName+"Data";
78 DataClassName = capIfaceName+"Data";
79 fqUsrParamClassName = cfg.packageName()+"."+cfg.className()+"."+DataClassName;
80 cbFuncJavaReturnType = javaCallback.cbFuncBinding.getJavaReturnType();
81 jcbNextIDVarName = "NEXT_"+capIfaceName+"_ID";
82
83 setFuncCBArgName = binding.getArgumentName(javaCallback.setFuncCBParamIdx);
84
85 userParamDefined = javaCallback.setFuncUserParamIdx >= 0;
86 if( !userParamDefined ) {
87 setFuncUserParamCType = null;
88 setFuncUserParamJType = null;
89 setFuncUserParamTypeName = null;
90 setFuncUserParamArgName = null;
91
92 userParamIsKey = false;
93 } else {
94 setFuncUserParamCType = mb.getCArgumentType(javaCallback.setFuncUserParamIdx);
95 setFuncUserParamJType = mb.getJavaArgumentType(javaCallback.setFuncUserParamIdx);
96 setFuncUserParamTypeName = setFuncUserParamJType.getName();
97 setFuncUserParamArgName = binding.getArgumentName(javaCallback.setFuncUserParamIdx);
98
99 userParamIsKey = info.setFuncKeyIndices.contains(info.setFuncUserParamIdx);
100 }
101 if( null != setFuncUserParamJType && !setFuncUserParamJType.isLong() ) {
102 if( setFuncUserParamJType.isCompoundTypeWrapper() ) {
103 userParamIsCompound = true;
104 userParamIsMappedToID = false;
105 userParamIDMapInstanceName = null;
106 } else {
107 userParamIsCompound = false;
108 userParamIsMappedToID = true;
109 userParamIDMapInstanceName = userParamIsKey ? lowIfaceName+"UserObjIDMap" : null;
110 }
111 } else {
112 userParamIsCompound = false;
113 userParamIsMappedToID = false;
114 userParamIDMapInstanceName = null;
115 }
116
117 if( userParamDefined ) {
118 if( userParamIsCompound ) {
119 userParamClassName = setFuncUserParamTypeName;
120 } else if( null != javaCallback.userParamClassName ) {
121 userParamClassName = javaCallback.userParamClassName;
122 } else {
123 userParamClassName = "Object";
124 }
125 } else {
126 userParamClassName = null;
127 }
128
129 if( null != javaCallback.customKeyClassName ) {
130 customKeyClass = true;
131 KeyClassName = javaCallback.customKeyClassName;
132 useDataMap = true;
133 } else {
134 customKeyClass = false;
135 KeyClassName = capIfaceName+"Key";
136 useDataMap = javaCallback.setFuncKeyIndices.size() > 0;
137 }
138 }
139
140 public void emitJavaAdditionalCode(final CodeUnit unit, final boolean isInterface) {
141 if( isInterface ) {
142 if( useDataMap ) {
143 if( !customKeyClass && !info.keyClassEmitted ) {
144 emitJavaKeyClass(unit);
145 unit.emitln();
146 info.keyClassEmitted = true;
147 }
148 emitJavaBriefAPIDoc(unit, "Returns ", "set of ", "", "for ");
149 unit.emitln(" public Set<"+KeyClassName+"> get"+capIfaceName+"Keys();");
150 unit.emitln();
151 emitJavaBriefAPIDoc(unit, "Returns ", "whether callback ", "if callback ", "is mapped for ");
152 unit.emitln(" public boolean is"+capIfaceName+"Mapped("+KeyClassName+" key);");
153 unit.emitln();
154 emitJavaBriefAPIDoc(unit, "Returns "+info.cbFuncTypeName+" callback ", "mapped to ", "", "for ");
155 unit.emitln(" public "+info.cbFuncTypeName+" get"+capIfaceName+"("+KeyClassName+" key);");
156 unit.emitln();
157 if( userParamDefined ) {
158 emitJavaBriefAPIDoc(unit, "Returns user-param ", "mapped to ", "", "for ");
159 unit.emitln(" public "+userParamClassName+" get"+capIfaceName+"UserParam("+KeyClassName+" key);");
160 unit.emitln();
161 }
162 emitJavaBriefAPIDoc(unit, "Releases all callback data ", "mapped via ", "", "skipping toolkit API. Favor passing `null` callback ref to ");
163 unit.emitln(" public int releaseAll"+capIfaceName+"();");
164 unit.emitln();
165 emitJavaBriefAPIDoc(unit, "Releases callback data ", "mapped to ", "", "skipping toolkit API. Favor passing `null` callback ref to ");
166 unit.emitln(" public void release"+capIfaceName+"("+KeyClassName+" key);");
167 unit.emitln();
168 } else {
169 emitJavaBriefAPIDoc(unit, "Returns ", "whether callback ", "if callback ", "is mapped for ");
170 unit.emitln(" public boolean is"+capIfaceName+"Mapped();");
171 unit.emitln();
172 emitJavaBriefAPIDoc(unit, "Returns "+info.cbFuncTypeName+" callback ", "mapped to ", "", "for ");
173 unit.emitln(" public "+info.cbFuncTypeName+" get"+capIfaceName+"();");
174 unit.emitln();
175 if( userParamDefined ) {
176 emitJavaBriefAPIDoc(unit, "Returns user-param ", "mapped to ", "", "for ");
177 unit.emitln(" public "+userParamClassName+" get"+capIfaceName+"UserParam();");
178 unit.emitln();
179 }
180 emitJavaBriefAPIDoc(unit, "Releases callback data ", "", "", "skipping toolkit API. Favor passing `null` callback ref to ");
181 unit.emitln(" public void release"+capIfaceName+"();");
182 unit.emitln();
183 }
184 } else {
185 if( useDataMap ) {
186 if( !customKeyClass && !info.keyClassEmitted ) {
187 emitJavaKeyClass(unit);
188 unit.emitln();
189 info.keyClassEmitted = true;
190 }
191 emitJavaBriefAPIDoc(unit, "Returns ", "set of ", "", "for ");
192 unit.emitln(" public final Set<"+KeyClassName+"> get"+capIfaceName+"Keys() {");
193 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
194 unit.emitln(" return "+dataMapInstanceName+".keySet();");
195 unit.emitln(" }");
196 unit.emitln(" }");
197 unit.emitln();
198 emitJavaBriefAPIDoc(unit, "Returns ", "whether callback ", "if callback ", "is mapped for ");
199 unit.emitln(" public final boolean is"+capIfaceName+"Mapped("+KeyClassName+" key) {");
200 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
201 unit.emitln(" return null != "+dataMapInstanceName+".get(key);");
202 unit.emitln(" }");
203 unit.emitln(" }");
204 unit.emitln();
205
206 emitJavaBriefAPIDoc(unit, "Returns "+info.cbFuncTypeName+" callback ", "mapped to ", "", "for ");
207 unit.emitln(" public final "+info.cbFuncTypeName+" get"+capIfaceName+"("+KeyClassName+" key) {");
208 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
209 unit.emitln(" final "+DataClassName+" value = "+dataMapInstanceName+".get(key);");
210 unit.emitln(" return null != value ? value.func : null;");
211 unit.emitln(" }");
212 unit.emitln(" }");
213 unit.emitln();
214
215 if( userParamDefined ) {
216 emitJavaBriefAPIDoc(unit, "Returns user-param ", "mapped to ", "", "for ");
217 unit.emitln(" public final "+userParamClassName+" get"+capIfaceName+"UserParam("+KeyClassName+" key) {");
218 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
219 unit.emitln(" final "+DataClassName+" value = "+dataMapInstanceName+".get(key);");
220 unit.emitln(" return null != value ? value.param : null;");
221 unit.emitln(" }");
222 unit.emitln(" }");
223 unit.emitln();
224 }
225 emitJavaBriefAPIDoc(unit, "Releases all callback data ", "mapped via ", "", "skipping toolkit API. Favor passing `null` callback ref to ");
226 unit.emitln(" public final int releaseAll"+capIfaceName+"() {");
227 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
228 unit.emitln(" final Set<"+KeyClassName+"> keySet = "+dataMapInstanceName+".keySet();");
229 unit.emitln(" final "+KeyClassName+"[] keys = keySet.toArray(new "+KeyClassName+"[keySet.size()]);");
230 unit.emitln(" for(int i=0; i<keys.length; ++i) {");
231 unit.emitln(" final "+KeyClassName+" key = keys[i];");
232 unit.emitln(" release"+capIfaceName+"(key);");
233 unit.emitln(" }");
234 unit.emitln(" return keys.length;");
235 unit.emitln(" }");
236 unit.emitln(" }");
237 unit.emitln();
238 emitJavaBriefAPIDoc(unit, "Releases callback data ", "mapped to ", "", "skipping toolkit API. Favor passing `null` callback ref to ");
239 unit.emitln(" public final void release"+capIfaceName+"("+KeyClassName+" key) {");
240 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
241 if( userParamIsMappedToID && userParamIsKey ) {
242 unit.emitln(" "+DataClassName+" value = "+dataMapInstanceName+".remove(key);");
243 unit.emitln(" if( null != value ) {");
244 unit.emitln(" "+userParamIDMapInstanceName+".remove(value.paramID);");
245 unit.emitln(" }");
246 } else {
247 unit.emitln(" /* "+DataClassName+" value = */ "+dataMapInstanceName+".remove(key);");
248 }
249 unit.emitln(" }");
250 unit.emitln(" }");
251 unit.emitln();
252 } else {
253 emitJavaBriefAPIDoc(unit, "Returns ", "whether callback ", "if callback ", "is mapped for ");
254 unit.emitln(" public final boolean is"+capIfaceName+"Mapped() {");
255 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
256 unit.emitln(" return null != "+dataInstanceName+";");
257 unit.emitln(" }");
258 unit.emitln(" }");
259 unit.emitln();
260
261 emitJavaBriefAPIDoc(unit, "Returns "+info.cbFuncTypeName+" callback ", "mapped to ", "", "for ");
262 unit.emitln(" public final "+info.cbFuncTypeName+" get"+capIfaceName+"() {");
263 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
264 unit.emitln(" final "+DataClassName+" value = "+dataInstanceName+";");
265 unit.emitln(" return null != value ? value.func : null;");
266 unit.emitln(" }");
267 unit.emitln(" }");
268 unit.emitln();
269
270 if( userParamDefined ) {
271 emitJavaBriefAPIDoc(unit, "Returns user-param ", "mapped to ", "", "for ");
272 unit.emitln(" public final "+userParamClassName+" get"+capIfaceName+"UserParam() {");
273 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
274 unit.emitln(" final "+DataClassName+" value = "+dataInstanceName+";");
275 unit.emitln(" return null != value ? value.param : null;");
276 unit.emitln(" }");
277 unit.emitln(" }");
278 unit.emitln();
279 }
280
281 emitJavaBriefAPIDoc(unit, "Releases callback data ", "", "", "skipping toolkit API. Favor passing `null` callback ref to ");
282 unit.emitln(" public final void release"+capIfaceName+"() {");
283 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
284 unit.emitln(" // final "+DataClassName+" value = "+dataInstanceName+";");
285 if( userParamIsMappedToID && userParamIsKey ) {
286 unit.emitln(" "+userParamIDMapInstanceName+".remove(dataInstanceName.paramID);");
287 }
288 unit.emitln(" "+dataInstanceName+" = null;");
289 unit.emitln(" }");
290 unit.emitln(" }");
291 unit.emitln();
292 }
293 unit.emitln(" private final void add"+capIfaceName+"("+binding.getJavaSelectParameter(new StringBuilder(), info.setFuncKeyIndices, true).toString()+DataClassName+" value) {");
294 if( useDataMap ) {
295 unit.emitln(" final "+KeyClassName+" key = new "+KeyClassName+"("+binding.getJavaCallSelectArguments(new StringBuilder(), info.setFuncKeyIndices, false).toString()+");");
296 if( userParamIsMappedToID && userParamIsKey ) {
297 unit.emitln(" final "+DataClassName+" old = "+dataMapInstanceName+".put(key, value);");
298 } else {
299 unit.emitln(" /* final "+DataClassName+" old = */ "+dataMapInstanceName+".put(key, value);");
300 }
301 } else {
302 if( userParamIsMappedToID && userParamIsKey ) {
303 unit.emitln(" final "+DataClassName+" old = "+dataInstanceName+";");
304 } else {
305 unit.emitln(" // final "+DataClassName+" old = "+dataInstanceName+";");
306 }
307 unit.emitln(" "+dataInstanceName+" = value;");
308 }
309 if( userParamIsMappedToID && userParamIsKey ) {
310 unit.emitln(" if( null != old ) {");
311 unit.emitln(" "+userParamIDMapInstanceName+".remove(old.paramID);");
312 unit.emitln(" }");
313 unit.emitln(" if( null != value.param ) {");
314 unit.emitln(" "+userParamIDMapInstanceName+".put(value.paramID, value.param);");
315 unit.emitln(" }");
316 }
317 unit.emitln(" }");
318 unit.emitln();
319 if( !cfg.emittedJavaCallbackUserParamClasses.contains(fqUsrParamClassName) ) {
320 emitJavaDataClass(unit);
321 cfg.emittedJavaCallbackUserParamClasses.add(fqUsrParamClassName);
322 }
323 if( useDataMap ) {
324 unit.emitln(" private static final Map<"+KeyClassName+", "+DataClassName+"> "+dataMapInstanceName+" = new HashMap<"+KeyClassName+", "+DataClassName+">();");
325 } else {
326 unit.emitln(" private static "+DataClassName+" "+dataInstanceName+" = null;");
327 }
328 if( userParamIsMappedToID && userParamIsKey ) {
329 unit.emitln(" private static final LongObjectHashMap "+userParamIDMapInstanceName+" = new LongObjectHashMap();");
330 }
331 unit.emitln(" private static long "+jcbNextIDVarName+" = 1;");
332 unit.emitln(" private static final Object "+lockInstanceName+" = new Object();");
333 unit.emitln();
334 emitJavaStaticCallback(unit);
335 }
336 }
337
338 private final void emitJavaBriefAPIDoc(final CodeUnit unit, final String actionText, final String relationToKey, final String noKeyText, final String relationToFunc) {
339 unit.emit(" /** "+actionText);
340 if( info.setFuncKeyIndices.size() > 0 ) {
341 unit.emit(relationToKey);
342 unit.emit("Key { "+binding.getJavaSelectParameter(new StringBuilder(), info.setFuncKeyIndices, false).toString()+" } ");
343 } else {
344 unit.emit(noKeyText);
345 }
346 unit.emit(relationToFunc);
347 unit.emitln("<br> <code>"+setFuncSignature+"</code> */");
348 }
349
350 private final void emitJavaKeyClass(final CodeUnit unit) {
351 if( cfg.shouldIgnoreInInterface(KeyClassName) ) return;
352
353 emitJavaBriefAPIDoc(unit, "", "", "", "for ");
354 unit.emitln(" public static class "+KeyClassName+" {");
355 binding.forEachParameter( ( final int idx, final int consumedCount, final Type cType, final JavaType jType, final String name ) -> {
356 if( !cType.isVoid() && info.setFuncKeyIndices.contains(idx) ) {
357 unit.emitln(" public final "+jType+" "+name+";");
358 return true;
359 } else {
360 return false;
361 }
362 } );
363 unit.emitln(" public "+KeyClassName+"("+binding.getJavaSelectParameter(new StringBuilder(), info.setFuncKeyIndices, false).toString()+") {");
364 binding.forEachParameter( ( final int idx, final int consumedCount, final Type cType, final JavaType jType, final String name ) -> {
365 if( !cType.isVoid() && info.setFuncKeyIndices.contains(idx) ) {
366 unit.emitln(" this."+name+" = "+name+";");
367 return true;
368 } else {
369 return false;
370 }
371 } );
372 unit.emitln(" }");
373 unit.emitln(" @Override");
374 unit.emitln(" public boolean equals(final Object o) {");
375 unit.emitln(" if( this == o ) {");
376 unit.emitln(" return true;");
377 unit.emitln(" }");
378 unit.emitln(" if( !(o instanceof "+KeyClassName+") ) {");
379 unit.emitln(" return false;");
380 unit.emitln(" }");
381 {
382 final int count = binding.forEachParameter( ( final int idx, final int consumedCount, final Type cType, final JavaType jType, final String name ) -> {
383 if( !cType.isVoid() && info.setFuncKeyIndices.contains(idx) ) {
384 if( 0 == consumedCount ) {
385 unit.emitln(" final "+KeyClassName+" o2 = ("+KeyClassName+")o;");
386 unit.emit (" return ");
387 } else {
388 unit.emitln(" &&");
389 unit.emit (" ");
390 }
391 if( jType.isCompoundTypeWrapper() ) {
392 unit.emit(name+".getDirectBufferAddress() == o2."+name+".getDirectBufferAddress()");
393 } else if( jType.isPrimitive() || idx == info.setFuncUserParamIdx ) {
394 unit.emit(name+" == o2."+name);
395 } else {
396 unit.emit(name+".equals( o2."+name+" )");
397 }
398 return true;
399 } else {
400 return false;
401 }
402 } );
403 if( 0 == count ) {
404 unit.emit(" return true");
405 }
406 unit.emitln(";");
407 }
408 unit.emitln(" }");
409 unit.emitln(" @Override");
410 unit.emitln(" public int hashCode() {");
411 {
412 final int count = binding.forEachParameter( ( final int idx, final int consumedCount, final Type cType, final JavaType jType, final String name ) -> {
413 if( !cType.isVoid() && info.setFuncKeyIndices.contains(idx) ) {
414 if( 0 == consumedCount ) {
415 unit.emitln(" // 31 * x == (x << 5) - x");
416 unit.emit (" int hash = ");
417 } else {
418 unit.emit (" hash = ((hash << 5) - hash) + ");
419 }
420 if( jType.isPrimitive() ) {
421 if( jType.isLong() ) {
422 unit.emitln("HashUtil.getAddrHash32_EqualDist( "+name+" );");
423 } else {
424 unit.emitln(name+";");
425 }
426 } else if( jType.isCompoundTypeWrapper() ) {
427 unit.emitln("HashUtil.getAddrHash32_EqualDist( "+name+".getDirectBufferAddress() );");
428 } else {
429 if( idx == info.setFuncUserParamIdx ) {
430 unit.emitln("System.identityHashCode( "+name+" );");
431 } else {
432 unit.emitln(name+".hashCode();");
433 }
434 }
435 return true;
436 } else {
437 return false;
438 }
439 } );
440 if( 0 == count ) {
441 unit.emitln(" return 0;");
442 } else {
443 unit.emitln(" return hash;");
444 }
445 }
446 unit.emitln(" }");
447 unit.emitln(" }");
448 }
449
450 private final void emitJavaDataClass(final CodeUnit unit) {
451 unit.emitln(" private static class "+DataClassName+" {");
452 unit.emitln(" final " + info.cbFuncTypeName + " func;");
453 if( userParamDefined ) {
454 unit.emitln(" // userParamArgCType "+setFuncUserParamCType);
455 unit.emitln(" // userParamArgJType "+setFuncUserParamJType);
456 unit.emitln(" final "+setFuncUserParamTypeName+" param;");
457 if( userParamIsMappedToID ) {
458 unit.emitln(" final long paramID;");
459 }
460 } else {
461 unit.emitln(" // No user param defined.");
462 }
463 unit.emit (" "+DataClassName+"(final "+info.cbFuncTypeName+" func");
464 if( userParamDefined ) {
465 if( userParamIsMappedToID ) {
466 unit.emit(", final long paramID");
467 }
468 unit.emit(", final "+setFuncUserParamTypeName+" param");
469 }
470 unit.emitln(") {");
471 unit.emitln(" this.func = func;");
472 if( userParamDefined ) {
473 if( userParamIsMappedToID ) {
474 unit.emitln(" this.paramID = paramID;");
475 }
476 unit.emitln(" this.param = param;");
477 }
478 unit.emitln(" }");
479 unit.emitln(" }");
480 }
481
482 public final String getJavaStaticCallbackSignature() {
483 final StringBuilder buf = new StringBuilder();
484 buf.append("(");
485 info.cbFuncBinding.forEachParameter( ( final int idx, final int consumedCount, final Type cType, final JavaType jType, final String name ) -> {
486 if( !cType.isVoid() && !jType.isPascalLen() ) {
487 if( idx == info.cbFuncUserParamIdx ) {
488 buf.append("J");
489 } else {
490 buf.append(jType.getDescriptor(cfg));
491 }
492 return true;
493 } else {
494 return false;
495 }
496 } );
497 buf.append(")");
498 buf.append(cbFuncJavaReturnType.getDescriptor(cfg));
499 return buf.toString();
500 }
501
502 public final int appendJavaAdditionalJNIParameter(final StringBuilder buf) {
503 buf.append("Class<?> staticCBClazz, String callbackSignature");
504 if( !userParamDefined ) {
505 return 2;
506 }
507 buf.append(", long nativeUserParam");
508 return 3;
509 }
510 public final int appendJavaAdditionalJNIArguments(final StringBuilder buf) {
511 buf.append("this.getClass(), \"" + getJavaStaticCallbackSignature() + "\"");
512 if( !userParamDefined ) {
513 return 2;
514 }
515 buf.append(", nativeUserParam");
516 return 3;
517 }
518
519 public void emitJavaSetFuncPreCall(final CodeUnit unit) {
520 if( userParamDefined ) {
521 unit.emitln(" final long nativeUserParam;");
522 }
523 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
524 if( userParamDefined ) {
525 if( setFuncUserParamJType.isLong() ) {
526 unit.emitln(" nativeUserParam = "+setFuncUserParamArgName+";");
527 } else {
528 unit.emitln(" if( null != "+setFuncUserParamArgName+" ) {");
529 if( setFuncUserParamJType.isCompoundTypeWrapper() ) {
530 // userParamIsCompound == true
531 unit.emitln(" nativeUserParam = "+setFuncUserParamArgName+".getDirectBufferAddress();");
532 } else {
533 // userParamIsMappedToID == true
534 unit.emitln(" nativeUserParam = "+jcbNextIDVarName+"++;");
535 unit.emitln(" if( 0 >= "+jcbNextIDVarName+" ) { "+jcbNextIDVarName+" = 1; }");
536 }
537 unit.emitln(" } else {");
538 unit.emitln(" nativeUserParam = 0;");
539 unit.emitln(" }");
540 }
541 }
542 unit.emitln(" if( null != "+setFuncCBArgName+" ) {");
543 unit.emit (" add"+capIfaceName+"("+binding.getJavaCallSelectArguments(new StringBuilder(), info.setFuncKeyIndices, true).toString()+
544 "new "+DataClassName+"("+setFuncCBArgName);
545 if( userParamDefined ) {
546 if( userParamIsMappedToID ) {
547 unit.emit(", nativeUserParam");
548 }
549 unit.emit(", "+setFuncUserParamArgName);
550 }
551 unit.emitln("));");
552 unit.emitln(" } else { ");
553 unit.emitln(" // release a previously mapped instance ");
554 if( useDataMap ) {
555 unit.emitln(" release"+capIfaceName+"( new "+KeyClassName+"( "+binding.getJavaCallSelectArguments(new StringBuilder(), info.setFuncKeyIndices, false).toString()+" ) );");
556 } else {
557 unit.emitln(" release"+capIfaceName+"();");
558 }
559 unit.emitln(" }");
560 unit.emitln(" } // synchronized ");
561 unit.emitln();
562 }
563
564 private final void emitJavaStaticCallback(final CodeUnit unit) {
565 unit.emitln(" /** Static callback invocation, dispatching to "+info.cbSimpleClazzName+" for callback <br> <code>"+
566 info.cbFuncType.toString(info.cbFuncTypeName, false, true)+"</code> */");
567 unit.emit (" /* pp */ static "+cbFuncJavaReturnType.getName()+" invoke"+capIfaceName+"(");
568 final boolean[] mapNativePtrToCompound = { false };
569 final JavaType[] origUserParamJType = { null };
570 info.cbFuncBinding.forEachParameter( ( final int idx, final int consumedCount, final Type cType, final JavaType jType, final String name ) -> {
571 if( !cType.isVoid() && !jType.isPascalLen() ) {
572 if( 0 < consumedCount ) { unit.emit(", "); }
573 if( idx == info.cbFuncUserParamIdx ) {
574 unit.emit("long nativeUserParam");
575 if( jType.isCompoundTypeWrapper() ) {
576 mapNativePtrToCompound[0] = true;
577 origUserParamJType[0] = jType;
578 }
579 } else {
580 unit.emit(jType+" "+name);
581 }
582 return true;
583 } else {
584 return false;
585 }
586 } );
587 unit.emitln(") {");
588 final boolean useParamLocal[] = { false };
589 if( userParamDefined ) {
590 if( mapNativePtrToCompound[0] ) {
591 unit.emitln(" final "+origUserParamJType[0]+" "+info.cbFuncUserParamName+" = "+origUserParamJType[0]+".derefPointer(nativeUserParam);");
592 useParamLocal[0] = true;
593 } else if( userParamIsMappedToID && userParamIsKey ) {
594 unit.emitln(" final "+userParamClassName+" "+info.cbFuncUserParamName+";");
595 }
596 }
597 unit.emitln(" final "+DataClassName+" value;");
598 unit.emitln(" synchronized( "+lockInstanceName+" ) {");
599 if( userParamDefined ) {
600 if( userParamIsMappedToID && userParamIsKey && !mapNativePtrToCompound[0] ) {
601 unit.emitln(" "+info.cbFuncUserParamName+" = ("+userParamClassName+") "+userParamIDMapInstanceName+".get(nativeUserParam);");
602 useParamLocal[0] = true;
603 }
604 }
605 if( useDataMap ) {
606 unit.emitln(" final "+KeyClassName+" key = new "+KeyClassName+"("+info.cbFuncBinding.getJavaCallSelectArguments(new StringBuilder(), info.cbFuncKeyIndices, false).toString()+");");
607 unit.emitln(" value = "+dataMapInstanceName+".get(key);");
608 } else {
609 unit.emitln(" value = "+dataInstanceName+";");
610 }
611 unit.emitln(" }");
612 unit.emitln(" if( null == value ) {");
613 if( !cbFuncJavaReturnType.isVoid() ) {
614 unit.emitln(" return 0;");
615 } else {
616 unit.emitln(" return;");
617 }
618 unit.emitln(" }");
619 if( !cbFuncJavaReturnType.isVoid() ) {
620 unit.emit(" return ");
621 } else {
622 unit.emit(" ");
623 }
624 unit.emit("value.func.callback(");
625 info.cbFuncBinding.forEachParameter( ( final int idx, final int consumedCount, final Type cType, final JavaType jType, final String name ) -> {
626 if( !cType.isVoid() && !jType.isPascalLen() ) {
627 if( 0 < consumedCount ) { unit.emit(", "); }
628 if( idx == info.cbFuncUserParamIdx && !useParamLocal[0] ) {
629 unit.emit("value.param");
630 } else {
631 unit.emit(name);
632 }
633 return true;
634 } else {
635 return false;
636 }
637 } );
638 unit.emitln(");");
639 unit.emitln(" }");
640 unit.emitln();
641 }
642
643 //
644 // C JNI Code ..
645 //
646
647 public int appendCAdditionalParameter(final StringBuilder buf) {
648 buf.append(", jclass staticCBClazz, jstring jcallbackSignature");
649 if( !userParamDefined ) {
650 return 2;
651 }
652 buf.append(", jlong jnativeUserParam");
653 return 3;
654 }
655
656 public void emitCOptArgumentSuffix(final CodeUnit unit, final int argIdx) {
657 if( ( argIdx == info.setFuncCBParamIdx || argIdx == info.setFuncUserParamIdx ) ) {
658 unit.emit("_native");
659 }
660 }
661
662 public void appendCAdditionalJNIDescriptor(final StringBuilder buf) {
663 JavaType.appendJNIDescriptor(buf, Class.class, false); // to account for the additional 'jclass staticCBClazz' parameter
664 JavaType.appendJNIDescriptor(buf, String.class, false); // to account for the additional 'jstring jcallbackSignature' parameter
665 if( userParamDefined ) {
666 JavaType.appendJNIDescriptor(buf, long.class, false); // to account for the additional 'long nativeUserParam' parameter
667 }
668 }
669
670 public void emitCSetFuncPreCall(final CodeUnit unit) {
671 final String jcbNativeBasename = CodeGenUtils.capitalizeString( info.setFuncName );
672 final String jcbFriendlyBasename = info.setFuncName+"("+info.cbSimpleClazzName+")";
673 final String staticBindingMethodName = "invoke"+jcbNativeBasename;
674 final String staticBindingClazzVarName = "staticCBClazz"+jcbNativeBasename;
675 final String staticBindingMethodIDVarName = "staticCBMethod"+jcbNativeBasename;
676 final String cbFuncArgName = binding.getArgumentName(info.setFuncCBParamIdx);
677 final String nativeCBFuncVarName = cbFuncArgName+"_native";
678 final String userParamTypeName, nativeUserParamVarName;
679 if( userParamDefined ) {
680 userParamTypeName = info.cbFuncUserParamType.getCName();
681 nativeUserParamVarName = binding.getArgumentName(info.setFuncUserParamIdx)+"_native";
682 } else {
683 userParamTypeName = null;
684 nativeUserParamVarName = null;
685 }
686 unit.emitln();
687 unit.emitln(" // JavaCallback handling");
688 unit.emitln(" if( NULL == staticCBClazz ) { (*env)->FatalError(env, \"NULL staticCBClazz passed to '"+jcbFriendlyBasename+"'\"); }");
689 unit.emitln(" "+info.cbFuncTypeName+" "+nativeCBFuncVarName+";");
690 if( userParamDefined ) {
691 unit.emitln(" "+userParamTypeName+"* "+nativeUserParamVarName+";");
692 }
693 unit.emitln(" if( NULL != "+cbFuncArgName+" ) {");
694 unit.emitln(" if( NULL == "+staticBindingClazzVarName+" || NULL == "+staticBindingMethodIDVarName+" ) {");
695 unit.emitln(" jclass staticCBClazz2 = (*env)->NewGlobalRef(env, staticCBClazz);");
696 unit.emitln(" if( NULL == staticCBClazz2 ) { (*env)->FatalError(env, \"Failed NewGlobalRef(staticCBClazz) in '"+jcbFriendlyBasename+"'\"); }");
697 unit.emitln(" const char* callbackSignature = (*env)->GetStringUTFChars(env, jcallbackSignature, (jboolean*)NULL);");
698 unit.emitln(" if( NULL == callbackSignature ) { (*env)->FatalError(env, \"Failed callbackSignature in '"+jcbFriendlyBasename+"'\"); }");
699 unit.emitln(" jmethodID cbMethodID = (*env)->GetStaticMethodID(env, staticCBClazz2, \""+staticBindingMethodName+"\", callbackSignature);");
700 unit.emitln(" if( NULL == cbMethodID ) {");
701 unit.emitln(" char cmsg[400];");
702 unit.emitln(" snprintf(cmsg, 400, \"Failed GetStaticMethodID of '"+staticBindingMethodName+"(%s)' in '"+jcbFriendlyBasename+"'\", callbackSignature);");
703 unit.emitln(" (*env)->FatalError(env, cmsg);");
704 unit.emitln(" }");
705 unit.emitln(" (*env)->ReleaseStringUTFChars(env, jcallbackSignature, callbackSignature);");
706 unit.emitln(" "+staticBindingClazzVarName+" = staticCBClazz2;");
707 unit.emitln(" "+staticBindingMethodIDVarName+" = cbMethodID;");
708 unit.emitln(" }");
709 final JavaType bbjt = JavaType.createForClass(ByteBuffer.class);
710 for (int i = 0; i < info.cbFuncBinding.getNumArguments(); i++) {
711 final String baseArgName = CodeGenUtils.capitalizeString( info.cbFuncBinding.getArgumentName(i) );
712 final JavaType currentJavaType = info.cbFuncBinding.getJavaArgumentType(i);
713 if( i != info.cbFuncUserParamIdx && currentJavaType.isCompoundTypeWrapper() ) {
714 final String staticBindingClazzArgVarName = "staticCBArg" + baseArgName + "Clazz"+jcbNativeBasename;
715 final String staticBindingMethodIDArgVarName = "staticCBArg" + baseArgName + "Method"+jcbNativeBasename;
716 unit.emitln(" if( NULL == "+staticBindingClazzArgVarName+" || NULL == "+staticBindingMethodIDArgVarName+" ) {");
717 final String argClassDescriptor = currentJavaType.getDescriptor(cfg);
718 final String argClassRef = currentJavaType.getName(cfg);
719 final String argClassLocation = argClassRef.replace(".", "/");
720 unit.emitln(" jclass "+staticBindingClazzArgVarName+"2 = (*env)->FindClass(env, \""+argClassLocation+"\");");
721 unit.emitln(" if( NULL == "+staticBindingClazzArgVarName+"2 ) { (*env)->FatalError(env, \"Failed FindClass("+argClassLocation+") in '"+jcbFriendlyBasename+"'\"); }");
722 unit.emitln(" jmethodID "+staticBindingMethodIDArgVarName+"2 = (*env)->GetStaticMethodID(env, "+staticBindingClazzArgVarName+"2, \"create\", \"("+bbjt.getDescriptor()+")"+argClassDescriptor+"\");");
723 unit.emitln(" if( NULL == "+staticBindingMethodIDArgVarName+"2 ) {");
724 unit.emitln(" char cmsg[400];");
725 unit.emitln(" snprintf(cmsg, 400, \"Failed GetStaticMethodID of '"+argClassRef+".create("+bbjt.getDescriptor()+")"+argClassDescriptor+" in "+jcbFriendlyBasename+"'\");");
726 unit.emitln(" (*env)->FatalError(env, cmsg);");
727 unit.emitln(" }");
728 unit.emitln(" "+staticBindingClazzArgVarName+" = "+staticBindingClazzArgVarName+"2;");
729 unit.emitln(" "+staticBindingMethodIDArgVarName+" = "+staticBindingMethodIDArgVarName+"2;");
730 unit.emitln(" }");
731 }
732 }
733 unit.emitln(" "+nativeCBFuncVarName+" = func"+jcbNativeBasename+";");
734 if( userParamDefined ) {
735 unit.emitln(" "+nativeUserParamVarName+" = ("+userParamTypeName+"*) jnativeUserParam;");
736 }
737 unit.emitln(" } else {");
738 unit.emitln(" "+nativeCBFuncVarName+" = NULL;");
739 if( userParamDefined ) {
740 unit.emitln(" "+nativeUserParamVarName+" = NULL;");
741 }
742 unit.emitln(" }");
743 unit.emitln();
744
745 }
746
747 /**
748 * Emit addition C code, i.e. global varialbles and static callback invocation
749 * @param unit output C code unit
750 * @param jcbFuncCMethodEmitter only used to access {@link CMethodBindingEmitter#emitBodyMapCToJNIType(int, boolean)}, a non-ideal hack! (FIXME)
751 */
752 public void emitCAdditionalCode(final CodeUnit unit, final CMethodBindingEmitter jcbFuncCMethodEmitter) {
753 final String jcbNativeBasename = CodeGenUtils.capitalizeString( info.setFuncName );
754 final String jcbFriendlyBasename = info.setFuncName+"("+info.cbSimpleClazzName+")";
755 final String staticBindingClazzVarName = "staticCBClazz"+jcbNativeBasename;
756 final String staticBindingMethodIDVarName = "staticCBMethod"+jcbNativeBasename;
757 final String staticCallbackName = "func"+jcbNativeBasename;
758 final String userParamTypeName, userParamArgName;
759 if( userParamDefined ) {
760 // final Type userParamType = javaCallback.cbFuncBinding.getCArgumentType(javaCallback.cbFuncUserParamIdx);
761 userParamTypeName = info.cbFuncUserParamType.getCName();
762 userParamArgName = info.cbFuncBinding.getArgumentName(info.cbFuncUserParamIdx);
763 } else {
764 userParamTypeName = null;
765 userParamArgName = null;
766 }
767 final Type cReturnType = info.cbFuncBinding.getCReturnType();
768 final JavaType jretType = info.cbFuncBinding.getJavaReturnType();
769 unit.emitln();
770 unit.emitln("static jclass "+staticBindingClazzVarName+" = NULL;");
771 unit.emitln("static jmethodID "+staticBindingMethodIDVarName+" = NULL;");
772 for (int i = 0; i < info.cbFuncBinding.getNumArguments(); i++) {
773 final String baseArgName = CodeGenUtils.capitalizeString( info.cbFuncBinding.getArgumentName(i) );
774 final JavaType currentJavaType = info.cbFuncBinding.getJavaArgumentType(i);
775 if( i != info.cbFuncUserParamIdx && currentJavaType.isCompoundTypeWrapper() ) {
776 final String staticBindingClazzArgVarName = "staticCBArg" + baseArgName + "Clazz"+jcbNativeBasename;
777 final String staticBindingMethodIDArgVarName = "staticCBArg" + baseArgName + "Method"+jcbNativeBasename;
778 unit.emitln("static jclass "+staticBindingClazzArgVarName+" = NULL;");
779 unit.emitln("static jmethodID "+staticBindingMethodIDArgVarName+" = NULL;");
780 }
781 }
782 unit.emitln();
783 // javaCallback.cbFuncCEmitter.emitSignature();
784 unit.emit("static "+cReturnType.getCName()+" "+staticCallbackName+"(");
785 // javaCallback.cbFuncCEmitter.emitArguments();
786 unit.emit(info.cbFuncBinding.getCParameterList(new StringBuilder(), false, null).toString());
787 unit.emitln(") {");
788 // javaCallback.cbFuncCEmitter.emitBody();
789 {
790 unit.emitln(" int detachJVM = 0;");
791 unit.emitln(" JNIEnv* env = JVMUtil_GetJNIEnv(1 /* daemon */, &detachJVM);");
792 unit.emitln(" jclass cbClazz = "+staticBindingClazzVarName+";");
793 unit.emitln(" jmethodID cbMethod = "+staticBindingMethodIDVarName+";");
794 for (int i = 0; i < info.cbFuncBinding.getNumArguments(); i++) {
795 final String baseArgName = CodeGenUtils.capitalizeString( info.cbFuncBinding.getArgumentName(i) );
796 final JavaType currentJavaType = info.cbFuncBinding.getJavaArgumentType(i);
797 if( i != info.cbFuncUserParamIdx && currentJavaType.isCompoundTypeWrapper() ) {
798 final String staticBindingClazzArgVarName = "staticCBArg" + baseArgName + "Clazz"+jcbNativeBasename;
799 final String staticBindingMethodIDArgVarName = "staticCBArg" + baseArgName + "Method"+jcbNativeBasename;
800 unit.emitln(" jclass cbClazzArg" + baseArgName+" = "+staticBindingClazzArgVarName+";");
801 unit.emitln(" jmethodID cbMethodArg" + baseArgName+" = "+staticBindingMethodIDArgVarName+";");
802 }
803 }
804 unit.emitln(" if( NULL == env || NULL == cbClazz || NULL == cbMethod ) {");
805 if( !cReturnType.isVoid() ) {
806 unit.emitln(" return 0;");
807 } else {
808 unit.emitln(" return;");
809 }
810 unit.emitln(" }");
811 // javaCallback.cbFuncCEmitter.emitBodyVariableDeclarations();
812 // javaCallback.cbFuncCEmitter.emitBodyUserVariableDeclarations();
813 // javaCallback.cbFuncCEmitter.emitBodyVariablePreCallSetup();
814 emitJavaCallbackBodyCToJavaPreCall(jcbFuncCMethodEmitter);
815
816 // javaCallback.cbFuncCEmitter.emitBodyCallCFunction();
817 if( userParamDefined ) {
818 unit.emitln(" "+userParamTypeName+"* "+userParamArgName+"_jni = ("+userParamTypeName+"*) "+userParamArgName+";");
819 }
820 unit.emitln(" // C Params: "+info.cbFuncBinding.getCParameterList(new StringBuilder(), false, null).toString());
821 unit.emitln(" // J Params: "+info.cbFuncBinding.getJavaParameterList(new StringBuilder()).toString());
822
823 final String returnStatement;
824 if( !cReturnType.isVoid() ) {
825 unit.emit(" "+cReturnType.getCName()+" _res = 0;");
826 returnStatement = "return _res;";
827 } else {
828 returnStatement = "return;";
829 }
830 if( !cReturnType.isVoid() ) {
831 unit.emit(" _res = ("+cReturnType.getCName()+") ");
832 } else {
833 unit.emit(" ");
834 }
835 unit.emit("(*env)->CallStatic" + CodeGenUtils.capitalizeString( jretType.getName() ) +"Method(env, cbClazz, cbMethod, ");
836 // javaCallback.cbFuncCEmitter.emitBodyPassCArguments();
837 emitCBodyPassArguments(unit);
838 unit.emitln(");");
839 unit.emitln(" if( (*env)->ExceptionCheck(env) ) {");
840 unit.emitln(" fprintf(stderr, \"Info: Callback '"+jcbFriendlyBasename+"': Exception in Java Callback caught:\\n\");");
841 unit.emitln(" (*env)->ExceptionDescribe(env);");
842 unit.emitln(" (*env)->ExceptionClear(env);");
843 unit.emitln(" }");
844
845 // javaCallback.cbFuncCEmitter.emitBodyUserVariableAssignments();
846 // javaCallback.cbFuncCEmitter.emitBodyVariablePostCallCleanup();
847 // javaCallback.cbFuncCEmitter.emitBodyMapCToJNIType(-1 /* return value */, true /* addLocalVar */)
848 unit.emitln(" JVMUtil_ReleaseJNIEnv(env, detachJVM);");
849 unit.emitln(" "+returnStatement);
850 }
851 unit.emitln("}");
852 unit.emitln();
853 }
854
855 private int emitJavaCallbackBodyCToJavaPreCall(final CMethodBindingEmitter ce) {
856 int count = 0;
857 for (int i = 0; i < ce.binding.getNumArguments(); i++) {
858 if( i == info.cbFuncUserParamIdx ) {
859 continue;
860 }
861 if( ce.emitBodyMapCToJNIType(i, true /* addLocalVar */) ) {
862 ++count;
863 }
864 }
865 return count;
866 }
867
868 private int emitCBodyPassArguments(final CodeUnit unit) {
869 int count = 0;
870 boolean needsComma = false;
871 for (int i = 0; i < info.cbFuncBinding.getNumArguments(); i++) {
872 final JavaType currentJavaType = info.cbFuncBinding.getJavaArgumentType(i);
873 if( !currentJavaType.isPascalLen() ) {
874 if (needsComma) {
875 unit.emit(", ");
876 needsComma = false;
877 }
878 final String baseArgName = info.cbFuncBinding.getArgumentName(i);
879 if( i != info.cbFuncUserParamIdx && currentJavaType.isCompoundTypeWrapper() ) {
880 final String cBaseArgName = CodeGenUtils.capitalizeString( baseArgName );
881 final String jniArgName = baseArgName + "_jni";
882 unit.emit( jniArgName + " != NULL ? " + "(*env)->CallStaticObjectMethod(env, cbClazzArg" + cBaseArgName + ", cbMethodArg" + cBaseArgName + ", " + jniArgName + ") : NULL" );
883 } else {
884 unit.emit( baseArgName + "_jni" );
885 }
886 needsComma = true;
887 ++count;
888 }
889 }
890 return count;
891 }
892
893
894}
Emits the C-side component of the Java<->C JNI binding to its CodeUnit, see FunctionEmitter.
boolean emitBodyMapCToJNIType(final int argIdx, final boolean addLocalVar)
Emit code, converting a C type into a java JNI-type.
static String decapitalizeString(final String string)
Converts first letter to lower case.
static String capitalizeString(final String string)
Converts first letter to upper case.
General code unit (a generated C or Java source file), covering multiple FunctionEmitter allowing to ...
Definition: CodeUnit.java:42
void emit(final String s)
Definition: CodeUnit.java:81
void emitCAdditionalCode(final CodeUnit unit, final CMethodBindingEmitter jcbFuncCMethodEmitter)
Emit addition C code, i.e.
void appendCAdditionalJNIDescriptor(final StringBuilder buf)
void emitJavaSetFuncPreCall(final CodeUnit unit)
final int appendJavaAdditionalJNIParameter(final StringBuilder buf)
void emitJavaAdditionalCode(final CodeUnit unit, final boolean isInterface)
JavaCallbackEmitter(final JavaConfiguration cfg, final MethodBinding mb, final JavaCallbackInfo javaCallback, final String setFuncSignature)
final int appendJavaAdditionalJNIArguments(final StringBuilder buf)
void emitCOptArgumentSuffix(final CodeUnit unit, final int argIdx)
int appendCAdditionalParameter(final StringBuilder buf)
JavaCallback compile time information, produced by JavaEmitter#beginFunctions(TypeDictionary,...
Parses and provides access to the contents of .cfg files for the JavaEmitter.
final boolean shouldIgnoreInInterface(final String symbol)
Variant of shouldIgnoreInInterface(AliasedSymbol), where this method only considers the current-name ...
Describes a java-side representation of a type that is used to represent the same data on both the Ja...
Definition: JavaType.java:54
static StringBuilder appendJNIDescriptor(final StringBuilder res, final Class<?> c, final boolean useTrueType)
Appends the native (JNI) method-name descriptor corresponding to the given Class<?...
Definition: JavaType.java:471
String getName()
Returns the Java type name corresponding to this type.
Definition: JavaType.java:339
static JavaType createForClass(final Class<?> clazz)
Creates a JavaType corresponding to the given Java type.
Definition: JavaType.java:197
String getDescriptor()
Returns the descriptor (internal type signature) corresponding to this type.
Definition: JavaType.java:362
Represents the binding of a C function to a Java method.
String getArgumentName(final int i)
Returns either the argument name specified by the underlying FunctionSymbol or a fabricated argument ...
StringBuilder getJavaCallSelectArguments(final StringBuilder buf, final List< Integer > include, final boolean addTailSeparator)
int forEachParameter(final ParameterConsumer c)
StringBuilder getJavaParameterList(final StringBuilder buf)
Returns the function parameter list, i.e.
StringBuilder getJavaSelectParameter(final StringBuilder buf, final List< Integer > include, final boolean addTailSeparator)
Returns the function parameter list, i.e.
JavaType getJavaArgumentType(final int i)
String getInterfaceName()
Returns the FunctionSymbol's current aliased API name for the interface.
StringBuilder getCParameterList(final StringBuilder buf, final boolean useTypedef, final String callingConvention)
Returns the function parameter list, i.e.
String toString()
Returns a string representation of this type.
final String getCName()
Returns the name of this type.
Definition: Type.java:132
final boolean isVoid()
Indicates whether this is a VoidType.
Definition: Type.java:415