41package com.jogamp.gluegen;
43import com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider;
44import com.jogamp.gluegen.JavaEmitter.EmissionStyle;
45import com.jogamp.gluegen.JavaEmitter.MethodAccess;
46import com.jogamp.gluegen.Logging.LoggerIf;
49import java.lang.reflect.Array;
51import java.util.regex.*;
53import com.jogamp.gluegen.jgram.*;
54import com.jogamp.gluegen.cgram.types.*;
56import static java.util.logging.Level.*;
57import static com.jogamp.gluegen.JavaEmitter.MethodAccess.*;
58import static com.jogamp.gluegen.JavaEmitter.EmissionStyle.*;
64 private int nestedReads;
65 private String libraryOnLoadName;
66 private String packageName;
67 private String implPackageName;
68 private String className;
69 private String implClassName;
73 public static String
NEWLINE = System.getProperty(
"line.separator");
79 private String javaOutputDir =
".";
84 private String outputRootDir =
null;
90 private String nativeOutputDir =
".";
96 private boolean nativeOutputUsesJavaHierarchy;
103 private boolean tagNativeBinding;
110 private boolean relaxedEqualSemanticsTest;
123 private final List<String> imports =
new ArrayList<String>();
130 private String gluegenRuntimePackage =
"com.jogamp.gluegen.runtime";
136 private String runtimeExceptionType =
"RuntimeException";
137 private String unsupportedExceptionType =
"UnsupportedOperationException";
139 private final Map<String, MethodAccess> accessControl =
new HashMap<String, MethodAccess>();
140 private final Map<String, TypeInfo> typeInfoMap =
new HashMap<String, TypeInfo>();
141 private final Set<String> returnsString =
new HashSet<String>();
142 private final Set<String> returnsStringOnly =
new HashSet<String>();
143 private final Map<String, JavaType> returnsOpaqueJType =
new HashMap<String, JavaType>();
144 private final Map<String, String> returnedArrayLengths =
new HashMap<String, String>();
145 private final Set<String> maxOneElement =
new HashSet<String>();
151 private final Map<String, List<Integer>> argumentsAreString =
new HashMap<String, List<Integer>>();
161 final String cbFuncTypeName;
162 final int cbFuncUserParamIdx;
163 final String setFuncName;
164 final int setFuncUserParamIdx;
165 final List<Integer> cbFuncKeyIndices =
new ArrayList<Integer>();
166 final String userParamClassName;
167 final String customKeyClassName;
168 final List<Integer> setFuncKeyIndices =
new ArrayList<Integer>();
169 JavaCallbackDef(
final String cbFuncTypeName,
final int cbFuncUserParamIdx,
final String setFuncName,
final int setFuncUserParamIdx,
170 final String userParamClassName,
final String customKeyClassName) {
171 this.cbFuncTypeName = cbFuncTypeName;
172 this.cbFuncUserParamIdx = cbFuncUserParamIdx;
173 this.setFuncName = setFuncName;
174 this.setFuncUserParamIdx = setFuncUserParamIdx;
175 this.userParamClassName = userParamClassName;
176 this.customKeyClassName = customKeyClassName;
180 return String.format(
"JavaCallbackDef[cbFunc[type %s, userParamIdx %d, keys %s], set[%s, keys %s, userParamIdx %d], Class[UserParam %s, Key %s]]",
181 cbFuncTypeName, cbFuncUserParamIdx, cbFuncKeyIndices.toString(), setFuncName, setFuncKeyIndices.toString(), setFuncUserParamIdx,
182 userParamClassName, customKeyClassName);
185 private final List<JavaCallbackDef> javaCallbackList =
new ArrayList<JavaCallbackDef>();
186 private final Map<String, JavaCallbackDef> javaCallbackSetFuncToDef =
new HashMap<String, JavaCallbackDef>();
188 private final Set<String> extendedIntfSymbolsIgnore =
new HashSet<String>();
189 private final Set<String> extendedIntfSymbolsOnly =
new HashSet<String>();
190 private final Set<String> extendedImplSymbolsIgnore =
new HashSet<String>();
191 private final Set<String> extendedImplSymbolsOnly =
new HashSet<String>();
192 private final Set<Pattern> ignores =
new HashSet<Pattern>();
193 private final Map<String, Pattern> ignoreMap =
new HashMap<String, Pattern>();
194 private final Set<Pattern> ignoreNots =
new HashSet<Pattern>();
195 private final Set<Pattern> unignores =
new HashSet<Pattern>();
196 private final Set<Pattern> unimplemented =
new HashSet<Pattern>();
197 private boolean forceUseNIOOnly4All =
false;
198 private final Set<String> useNIOOnly =
new HashSet<String>();
199 private boolean forceUseNIODirectOnly4All =
false;
200 private final Set<String> useNIODirectOnly =
new HashSet<String>();
201 private final Set<String> immutableAccessSymbols =
new HashSet<String>();
202 private final Set<String> manuallyImplement =
new HashSet<String>();
203 private final Map<String, String> delegatedImplementation =
new HashMap<String, String>();
204 private final Map<String, List<String>> customJavaCode =
new HashMap<String, List<String>>();
205 private final Map<String, List<String>> customJNICode =
new HashMap<String, List<String>>();
206 private final Map<String, List<String>> classJavadoc =
new HashMap<String, List<String>>();
207 private final Map<String, List<String>> methodJavadoc =
new HashMap<String, List<String>>();
208 private final Map<String, String> structPackages =
new HashMap<String, String>();
209 private final List<String> customCCode =
new ArrayList<String>();
210 private final List<String> forcedStructs =
new ArrayList<String>();
211 private final Map<String, String> structMachineDataInfoIndex =
new HashMap<String, String>();
212 private final Map<String, String> returnValueCapacities =
new HashMap<String, String>();
213 private final Map<String, String> returnValueLengths =
new HashMap<String, String>();
214 private final Map<String, List<String>> temporaryCVariableDeclarations =
new HashMap<String, List<String>>();
215 private final Map<String, List<String>> temporaryCVariableAssignments =
new HashMap<String, List<String>>();
216 private final Map<String, List<String>> extendedInterfaces =
new HashMap<String, List<String>>();
217 private final Map<String, List<String>> implementedInterfaces =
new HashMap<String, List<String>>();
218 private final Map<String, String> parentClass =
new HashMap<String, String>();
219 private final Map<String, String> javaTypeRenames =
new HashMap<String, String>();
220 private final Map<String, String> javaSymbolRenames =
new HashMap<String, String>();
221 private final Map<String, Set<String>> javaRenamedSymbols =
new HashMap<String, Set<String>>();
222 private final Map<String, List<String>> javaPrologues =
new HashMap<String, List<String>>();
223 private final Map<String, List<String>> javaEpilogues =
new HashMap<String, List<String>>();
232 public final void read(
final String filename)
throws IOException {
233 read(filename,
null);
242 protected final void read(
final String filename,
final String linePrefix)
throws IOException {
243 final File file =
new File(filename);
244 BufferedReader reader =
null;
246 reader =
new BufferedReader(
new FileReader(file));
248 catch (
final FileNotFoundException fnfe) {
249 throw new RuntimeException(
"Could not read file \"" + file +
"\"", fnfe);
253 final boolean hasPrefix = linePrefix !=
null && linePrefix.length() > 0;
256 while ((line = reader.readLine()) !=
null) {
259 line = linePrefix +
" " + line;
262 if (line.trim().startsWith(
"#")) {
267 final StringTokenizer tok =
new StringTokenizer(line);
268 if (tok.hasMoreTokens()) {
270 final String cmd = tok.nextToken(
" \t\n\r\f");
272 dispatch(cmd, tok, file, filename, lineNo);
280 if (nestedReads == 0) {
281 if (
allStatic() && implClassName !=
null) {
282 throw new IllegalStateException(
"Error in configuration file \"" + filename +
"\": Cannot use " +
283 "directive \"ImplJavaClass\" in conjunction with " +
284 "\"Style AllStatic\"");
287 if (className ==
null && (emissionStyle() != ImplOnly)) {
290 if (packageName ==
null && (emissionStyle() != ImplOnly)) {
291 throw new RuntimeException(
"Output package name was not specified in configuration file \"" + filename +
"\"");
295 implClassName = className;
298 implPackageName = packageName;
300 if (implClassName ==
null) {
303 if (className ==
null) {
304 throw new RuntimeException(
"If ImplJavaClass is not specified, must specify JavaClass");
306 implClassName = className +
"Impl";
308 if (implPackageName ==
null) {
311 if (packageName ==
null) {
312 throw new RuntimeException(
"If ImplPackageName is not specified, must specify PackageName");
314 implPackageName = packageName +
".impl";
324 return libraryOnLoadName;
334 return implPackageName;
344 return implClassName;
348 return className ==
null && implClassName ==
null;
353 return (
null != outputRootDir) ? (outputRootDir +
"/" + javaOutputDir) : javaOutputDir;
358 return (
null != outputRootDir) ? (outputRootDir +
"/" + nativeOutputDir) : nativeOutputDir;
363 return nativeOutputUsesJavaHierarchy;
368 return tagNativeBinding;
377 return relaxedEqualSemanticsTest;
382 return emissionStyle;
402 return gluegenRuntimePackage;
407 return runtimeExceptionType;
412 return unsupportedExceptionType;
420 private static final boolean DEBUG_TYPE_INFO =
false;
434 return typeInfoMap.get(canonicalName);
445 System.err.println(
"Incoming type = " + type +
", " + type.
getDebugString());
447 for (
int i = 0; i <= pointerDepth; i++) {
449 if (DEBUG_TYPE_INFO) {
450 System.err.printf(
" [%2d] Name = %s%n", i, name);
456 final TypeInfo res = promoteTypeInfo(info, i);
457 if (DEBUG_TYPE_INFO) {
458 System.err.printf(
" [A][%2d] name %s%n", i, name);
459 System.err.printf(
" [A][%2d] info %s%n", i, info.
toString());
460 System.err.printf(
" [A][%2d] res %s%n", i, res.
toString());
472 final TypeInfo res = promoteTypeInfo(info, i);
473 if (DEBUG_TYPE_INFO) {
474 System.err.printf(
" [A][%2d] name %s%n", i, name);
475 System.err.printf(
" [A][%2d] info %s%n", i, info.
toString());
476 System.err.printf(
" [A][%2d] res %s%n", i, res.
toString());
487 if (DEBUG_TYPE_INFO) {
488 System.err.println(
" [X] NULL");
494 private TypeInfo closestTypeInfo(
final String name,
final int pointerDepth) {
495 TypeInfo info = typeInfoMap.get(name);
497 while (info !=
null) {
498 if (DEBUG_TYPE_INFO) {
499 System.err.println(
" Checking TypeInfo for " + name +
" at pointerDepth " + pointerDepth);
501 if (info.pointerDepth() <= pointerDepth && (closest ==
null || info.pointerDepth() > closest.pointerDepth())) {
502 if (DEBUG_TYPE_INFO) {
503 System.err.println(
" Accepted");
513 private TypeInfo promoteTypeInfo(
final TypeInfo info,
final int numPointersStripped) {
514 final int pd = info.pointerDepth();
515 int diff = numPointersStripped - pd;
521 throw new RuntimeException(
"TypeInfo for " + info.name() +
" and pointerDepth " +
522 info.pointerDepth() +
" should not have matched for depth " +
523 numPointersStripped);
526 Class<?> c = info.javaType().getJavaClass();
533 if (c == Boolean.TYPE) jt = JavaType.createForCCharPointer();
534 else if (c == Byte.TYPE) jt = JavaType.createForCCharPointer();
535 else if (c == Short.TYPE) jt = JavaType.createForCShortPointer();
536 else if (c == Integer.TYPE) jt = JavaType.createForCInt32Pointer();
537 else if (c == Long.TYPE) jt = JavaType.createForCInt64Pointer();
538 else if (c == Float.TYPE) jt = JavaType.createForCFloatPointer();
539 else if (c == Double.TYPE) jt = JavaType.createForCDoublePointer();
542 return new TypeInfo(info.name(), numPointersStripped, jt);
546 c = Array.newInstance(c, 0).getClass();
550 return new TypeInfo(info.name(),
552 JavaType.createForClass(c));
559 return returnsString.contains(functionName);
565 return returnsString.contains( symbol.
getName() ) ||
573 return returnsStringOnly.contains(functionName);
578 return javaCallbackList;
583 final String name = symbol.
getName();
588 res =
oneInMap(javaCallbackSetFuncToDef, aliases);
609 return returnedArrayLengths.get(symbol);
618 return maxOneElement.contains(symbol);
625 final String name = symbol.
getName();
628 List<Integer> res = argumentsAreString.get(name);
630 res =
oneInMap(argumentsAreString, aliases);
643 final String name = symbol.
getName();
648 res =
oneInMap(argumentsArePascalString, aliases);
660 useNIOOnly.add(fname);
666 return useNIODirectOnly(functionName) || forceUseNIOOnly4All || useNIOOnly.contains(functionName);
670 useNIODirectOnly.add(fname);
678 return forceUseNIODirectOnly4All || useNIODirectOnly.contains(functionName);
686 List<String> res = customJavaCode.get(className);
688 res =
new ArrayList<String>();
689 customJavaCode.put(className, res);
699 List<String> res = customJNICode.get(className);
701 res =
new ArrayList<String>();
702 customJNICode.put(className, res);
708 List<String> res = methodJavadoc.get(methodName);
710 res =
new ArrayList<String>();
711 methodJavadoc.put(methodName, res);
721 List<String> res = classJavadoc.get(className);
723 res =
new ArrayList<String>();
724 classJavadoc.put(className, res);
733 String res = structPackages.get(structName);
749 return forcedStructs;
763 return structMachineDataInfoIndex.get(structName);
776 return returnValueCapacities.get(functionName);
788 return returnValueLengths.get(symbol);
794 return temporaryCVariableDeclarations.get(functionName);
801 return temporaryCVariableAssignments.get(functionName);
808 List<String> res = extendedInterfaces.get(interfaceName);
810 res =
new ArrayList<String>();
811 extendedInterfaces.put(interfaceName, res);
820 List<String> res = implementedInterfaces.get(className);
822 res =
new ArrayList<String>();
823 implementedInterfaces.put(className, res);
832 return parentClass.get(className);
837 loggedIgnores =
true;
841 private static boolean loggedIgnores =
false;
844 LOG.
log(INFO,
"Extended Intf: {0}", extendedIntfSymbolsIgnore.size());
845 for (
final String str : extendedIntfSymbolsIgnore) {
846 LOG.
log(INFO,
"\t{0}", str);
848 LOG.
log(INFO,
"Extended Impl: {0}", extendedImplSymbolsIgnore.size());
849 for (
final String str : extendedImplSymbolsIgnore) {
850 LOG.
log(INFO,
"\t{0}", str);
852 LOG.
log(INFO,
"Ignores (All): {0}", ignores.size());
853 for (
final Pattern pattern : ignores) {
854 LOG.
log(INFO,
"\t{0}", pattern);
860 loggedRenames =
true;
864 private static boolean loggedRenames =
false;
867 LOG.
log(INFO,
"Symbol Renames: {0}", javaSymbolRenames.size());
868 for (
final String key : javaSymbolRenames.keySet()) {
869 LOG.
log(INFO,
"\t{0} -> {1}", key, javaSymbolRenames.get(key));
872 LOG.
log(INFO,
"Symbol Aliasing (through renaming): {0}", javaSymbolRenames.size());
873 for(
final String newName : javaSymbolRenames.values()) {
874 final Set<String> origNames = javaRenamedSymbols.get(newName);
875 if(
null!=origNames) {
876 LOG.
log(INFO,
"\t{0} <- {1}", newName, origNames);
881 public static <K,V> V
oneInMap(
final Map<K, V> map,
final Set<K> symbols) {
882 if(
null != map && map.size() > 0 &&
883 null != symbols && symbols.size() > 0 ) {
884 for(
final K sym : symbols) {
885 final V v = map.get(sym);
893 public static <K>
boolean oneInSet(
final Set<K> set1,
final Set<K> set2) {
894 if(
null != set1 && set1.size() > 0 &&
895 null != set2 && set2.size() > 0 ) {
896 for(
final K sym : set2) {
897 if( set1.contains( sym ) ) {
904 private static boolean onePatternMatch(
final Pattern ignoreRegexp,
final Set<String>
set) {
905 if(
null != ignoreRegexp &&
null !=
set &&
set.size() > 0 ) {
906 for(
final String sym :
set) {
907 final Matcher matcher = ignoreRegexp.matcher(sym);
908 if (matcher.matches()) {
928 return structName+
"."+fieldName;
940 final String name = symbol.
getName();
943 if ( immutableAccessSymbols.contains( name ) ||
944 oneInSet(immutableAccessSymbols, aliases)
961 if ( immutableAccessSymbols.contains( symbol ) ) {
962 LOG.
log(INFO,
"Immutable access: {0}", symbol);
974 if( manuallyImplement.contains(functionName) ) {
975 LOG.
log(INFO,
"ManuallyImplement: \"{0}\"", functionName);
996 final String name = symbol.
getName();
999 if ( manuallyImplement.contains( name ) ||
1000 oneInSet(manuallyImplement, aliases)
1016 final String res = delegatedImplementation.get(functionName);
1020 LOG.
log(INFO,
"DelegatedImplementation: {0} -> {1}", functionName, res);
1044 final String name = symbol.
getName();
1047 String res = delegatedImplementation.get(name);
1049 res =
oneInMap(delegatedImplementation, aliases);
1064 final JavaType res = returnsOpaqueJType.get(functionName);
1068 LOG.
log(INFO,
"ReturnsOpaque: {0} -> {1}", functionName, res);
1080 final String name = symbol.
getName();
1082 JavaType res = returnsOpaqueJType.get(name);
1084 res =
oneInMap(returnsOpaqueJType, aliases);
1122 final String name = symbol.
getName();
1126 if ( extendedIntfSymbolsIgnore.contains( name ) ||
1127 oneInSet(extendedIntfSymbolsIgnore, aliases)
1134 if ( !extendedIntfSymbolsOnly.isEmpty() &&
1135 !extendedIntfSymbolsOnly.contains( name ) &&
1136 !
oneInSet(extendedIntfSymbolsOnly, aliases) ) {
1161 final String name = symbol.
getName();
1165 if ( extendedImplSymbolsIgnore.contains( name ) ||
1166 oneInSet(extendedImplSymbolsIgnore, aliases)
1173 if ( !extendedImplSymbolsOnly.isEmpty() &&
1174 !extendedImplSymbolsOnly.contains( name ) &&
1175 !
oneInSet(extendedImplSymbolsOnly, aliases) ) {
1182 for (
final Pattern ignoreRegexp : ignores) {
1183 final Matcher matcher = ignoreRegexp.matcher(name);
1184 if ( matcher.matches() || onePatternMatch(ignoreRegexp, aliases) ) {
1191 if (ignoreNots.size() > 0) {
1194 for (
final Pattern ignoreNotRegexp : ignoreNots) {
1195 final Matcher matcher = ignoreNotRegexp.matcher(name);
1196 if ( !matcher.matches() && !onePatternMatch(ignoreNotRegexp, aliases) ) {
1199 if(unignores.isEmpty()) {
1203 boolean unignoreFound =
false;
1204 for (
final Pattern unignoreRegexp : unignores) {
1205 final Matcher unignoreMatcher = unignoreRegexp.matcher(name);
1206 if ( unignoreMatcher.matches() || onePatternMatch(unignoreRegexp, aliases) ) {
1207 unignoreFound =
true;
1212 if (!unignoreFound) {
1228 for (
final Pattern unimplRegexp : unimplemented) {
1229 final Matcher matcher = unimplRegexp.matcher(symbol.
getName());
1230 if ( matcher.matches() || onePatternMatch(unimplRegexp, symbol.
getAliasedNames()) ) {
1256 final String rename = javaTypeRenames.get(javaTypeName);
1257 if (rename !=
null) {
1260 return javaTypeName;
1272 return javaSymbolRenames.get(origName);
1277 return javaRenamedSymbols.get(aliasedName);
1282 LOG.
log(INFO,
"\tRename {0} -> {1}", origName, newName);
1283 final String prevValue = javaSymbolRenames.put(origName, newName);
1284 if(
null != prevValue && !prevValue.equals(newName)) {
1285 throw new RuntimeException(
"Rename-Override Attampt: "+origName+
" -> "+newName+
1286 ", but "+origName+
" -> "+prevValue+
" already exist. Run in 'debug' mode to analyze!");
1288 Set<String> origNames = javaRenamedSymbols.get(newName);
1289 if(
null == origNames) {
1290 origNames =
new HashSet<String>();
1291 javaRenamedSymbols.put(newName, origNames);
1293 origNames.add(origName);
1298 LOG.
log(INFO,
"\tDelegateImplementation {0} -> {1}", origName, renamedImpl);
1299 final String prevValue = delegatedImplementation.put(origName, renamedImpl);
1300 if(
null != prevValue && !prevValue.equals(renamedImpl)) {
1301 throw new RuntimeException(
"Rename-Override Attampt: "+origName+
" -> "+renamedImpl+
1302 ", but "+origName+
" -> "+prevValue+
" already exist. Run in 'debug' mode to analyze!");
1308 return emissionStyle == AllStatic;
1313 return emissionStyle() == InterfaceAndImpl || emissionStyle() == InterfaceOnly;
1318 return emissionStyle() == AllStatic || emissionStyle() == InterfaceAndImpl || emissionStyle() == ImplOnly;
1325 final boolean forImplementingMethodCall,
1326 final boolean eraseBufferAndArrayTypes) {
1327 List<String> res = javaPrologues.get(binding.
getName());
1330 res = javaPrologues.get(binding.
getName() + binding.
getDescriptor(forImplementingMethodCall, eraseBufferAndArrayTypes));
1339 final boolean forImplementingMethodCall,
1340 final boolean eraseBufferAndArrayTypes) {
1341 List<String> res = javaEpilogues.get(binding.
getName());
1344 res = javaEpilogues.get(binding.
getName() + binding.
getDescriptor(forImplementingMethodCall, eraseBufferAndArrayTypes));
1353 protected void dispatch(
final String cmd,
final StringTokenizer tok,
final File file,
final String filename,
final int lineNo)
throws IOException {
1355 if (cmd.equalsIgnoreCase(
"LibraryOnLoad")) {
1356 libraryOnLoadName =
readString(
"LibraryOnLoad", tok, filename, lineNo);
1357 }
else if (cmd.equalsIgnoreCase(
"Package")) {
1358 packageName =
readString(
"Package", tok, filename, lineNo);
1359 }
else if (cmd.equalsIgnoreCase(
"GlueGenRuntimePackage")) {
1360 gluegenRuntimePackage =
readString(
"GlueGenRuntimePackage", tok, filename, lineNo);
1361 }
else if (cmd.equalsIgnoreCase(
"ImplPackage")) {
1362 implPackageName =
readString(
"ImplPackage", tok, filename, lineNo);
1363 }
else if (cmd.equalsIgnoreCase(
"JavaClass")) {
1364 className =
readString(
"JavaClass", tok, filename, lineNo);
1365 }
else if (cmd.equalsIgnoreCase(
"ImplJavaClass")) {
1366 implClassName =
readString(
"ImplJavaClass", tok, filename, lineNo);
1367 }
else if (cmd.equalsIgnoreCase(
"JavaOutputDir")) {
1368 javaOutputDir =
readString(
"JavaOutputDir", tok, filename, lineNo);
1369 }
else if (cmd.equalsIgnoreCase(
"NativeOutputDir")) {
1370 nativeOutputDir =
readString(
"NativeOutputDir", tok, filename, lineNo);
1371 }
else if (cmd.equalsIgnoreCase(
"HierarchicalNativeOutput")) {
1372 final String tmp =
readString(
"HierarchicalNativeOutput", tok, filename, lineNo);
1373 nativeOutputUsesJavaHierarchy = Boolean.valueOf(tmp).booleanValue();
1374 }
else if (cmd.equalsIgnoreCase(
"TagNativeBinding")) {
1375 tagNativeBinding =
readBoolean(
"TagNativeBinding", tok, filename, lineNo).booleanValue();
1376 }
else if (cmd.equalsIgnoreCase(
"RelaxedEqualSemanticsTest")) {
1377 relaxedEqualSemanticsTest =
readBoolean(
"RelaxedEqualSemanticsTest", tok, filename, lineNo).booleanValue();
1378 TypeConfig.setRelaxedEqualSemanticsTest(relaxedEqualSemanticsTest);
1379 }
else if (cmd.equalsIgnoreCase(
"Style")) {
1382 }
catch(
final IllegalArgumentException ex) {
1383 LOG.
log(WARNING,
"Error parsing \"style\" command at line {0} in file \"{1}\"", lineNo, filename);
1385 }
else if (cmd.equalsIgnoreCase(
"AccessControl")) {
1387 }
else if (cmd.equalsIgnoreCase(
"Import")) {
1388 imports.add(
readString(
"Import", tok, filename, lineNo));
1389 }
else if (cmd.equalsIgnoreCase(
"Opaque")) {
1391 }
else if (cmd.equalsIgnoreCase(
"ReturnsString")) {
1393 }
else if (cmd.equalsIgnoreCase(
"ReturnsStringOnly")) {
1395 }
else if (cmd.equalsIgnoreCase(
"ReturnsOpaque")) {
1397 }
else if (cmd.equalsIgnoreCase(
"ReturnedArrayLength")) {
1401 }
else if (cmd.equalsIgnoreCase(
"MaxOneElement")) {
1403 }
else if (cmd.equalsIgnoreCase(
"ArgumentIsString")) {
1405 }
else if (cmd.equalsIgnoreCase(
"ArgumentIsPascalString")) {
1407 }
else if (cmd.equalsIgnoreCase(
"JavaCallbackDef")) {
1409 }
else if (cmd.equalsIgnoreCase(
"JavaCallbackKey")) {
1411 }
else if (cmd.equalsIgnoreCase(
"ExtendedInterfaceSymbolsIgnore")) {
1413 }
else if (cmd.equalsIgnoreCase(
"ExtendedInterfaceSymbolsOnly")) {
1415 }
else if (cmd.equalsIgnoreCase(
"ExtendedImplementationSymbolsIgnore")) {
1417 }
else if (cmd.equalsIgnoreCase(
"ExtendedImplementationSymbolsOnly")) {
1419 }
else if (cmd.equalsIgnoreCase(
"ExtendedIntfAndImplSymbolsIgnore")) {
1421 }
else if (cmd.equalsIgnoreCase(
"ExtendedIntfAndImplSymbolsOnly")) {
1423 }
else if (cmd.equalsIgnoreCase(
"Ignore")) {
1425 }
else if (cmd.equalsIgnoreCase(
"Unignore")) {
1427 }
else if (cmd.equalsIgnoreCase(
"IgnoreNot")) {
1429 }
else if (cmd.equalsIgnoreCase(
"Unimplemented")) {
1431 }
else if (cmd.equalsIgnoreCase(
"IgnoreField")) {
1433 }
else if (cmd.equalsIgnoreCase(
"ImmutableAccess")) {
1435 }
else if (cmd.equalsIgnoreCase(
"ManuallyImplement")) {
1437 }
else if (cmd.equalsIgnoreCase(
"CustomJavaCode")) {
1441 }
else if (cmd.equalsIgnoreCase(
"CustomCCode")) {
1445 }
else if (cmd.equalsIgnoreCase(
"CustomJNICode")) {
1449 }
else if (cmd.equalsIgnoreCase(
"MethodJavadoc")) {
1453 }
else if (cmd.equalsIgnoreCase(
"ClassJavadoc")) {
1457 }
else if (cmd.equalsIgnoreCase(
"NIOOnly")) {
1458 final String funcName =
readString(
"NIOOnly", tok, filename, lineNo);
1459 if(funcName.equals(
"__ALL__")) {
1460 forceUseNIOOnly4All=
true;
1464 }
else if (cmd.equalsIgnoreCase(
"NIODirectOnly")) {
1465 final String funcName =
readString(
"NIODirectOnly", tok, filename, lineNo);
1466 if(funcName.equals(
"__ALL__")) {
1467 forceUseNIODirectOnly4All=
true;
1471 }
else if (cmd.equalsIgnoreCase(
"EmitStruct")) {
1472 forcedStructs.add(
readString(
"EmitStruct", tok, filename, lineNo));
1473 }
else if (cmd.equalsIgnoreCase(
"StructPackage")) {
1475 }
else if (cmd.equalsIgnoreCase(
"TemporaryCVariableDeclaration")) {
1479 }
else if (cmd.equalsIgnoreCase(
"TemporaryCVariableAssignment")) {
1483 }
else if (cmd.equalsIgnoreCase(
"StructMachineDataInfoIndex")) {
1487 }
else if (cmd.equalsIgnoreCase(
"ReturnValueCapacity")) {
1491 }
else if (cmd.equalsIgnoreCase(
"ReturnValueLength")) {
1495 }
else if (cmd.equalsIgnoreCase(
"Include")) {
1497 }
else if (cmd.equalsIgnoreCase(
"IncludeAs")) {
1499 }
else if (cmd.equalsIgnoreCase(
"Extends")) {
1501 }
else if (cmd.equalsIgnoreCase(
"Implements")) {
1503 }
else if (cmd.equalsIgnoreCase(
"ParentClass")) {
1505 }
else if (cmd.equalsIgnoreCase(
"RenameJavaType")) {
1507 }
else if (cmd.equalsIgnoreCase(
"RenameJavaSymbol")) {
1509 }
else if (cmd.equalsIgnoreCase(
"DelegateImplementation")) {
1511 }
else if (cmd.equalsIgnoreCase(
"RuntimeExceptionType")) {
1512 runtimeExceptionType =
readString(
"RuntimeExceptionType", tok, filename, lineNo);
1513 }
else if (cmd.equalsIgnoreCase(
"UnsupportedExceptionType")) {
1514 unsupportedExceptionType =
readString(
"UnsupportedExceptionType", tok, filename, lineNo);
1515 }
else if (cmd.equalsIgnoreCase(
"JavaPrologue")) {
1519 }
else if (cmd.equalsIgnoreCase(
"JavaEpilogue")) {
1523 }
else if (cmd.equalsIgnoreCase(
"RangeCheck")) {
1527 }
else if (cmd.equalsIgnoreCase(
"RangeCheckBytes")) {
1532 throw new RuntimeException(
"Unknown command \"" + cmd +
1533 "\" in command file " + filename +
1534 " at line number " + lineNo);
1538 protected String
readString(
final String cmd,
final StringTokenizer tok,
final String filename,
final int lineNo) {
1540 return tok.nextToken();
1541 }
catch (
final NoSuchElementException e) {
1542 throw new RuntimeException(
"Error parsing \"" + cmd +
"\" command at line " + lineNo +
1543 " in file \"" + filename +
"\": missing expected parameter", e);
1547 protected Boolean
readBoolean(
final String cmd,
final StringTokenizer tok,
final String filename,
final int lineNo) {
1549 return Boolean.valueOf(tok.nextToken());
1550 }
catch (
final NoSuchElementException e) {
1551 throw new RuntimeException(
"Error parsing \"" + cmd +
"\" command at line " + lineNo +
1552 " in file \"" + filename +
"\": missing expected boolean value", e);
1557 if (type.equals(
"boolean"))
return Boolean.TYPE;
1558 if (type.equals(
"byte"))
return Byte.TYPE;
1559 if (type.equals(
"char"))
return Character.TYPE;
1560 if (type.equals(
"short"))
return Short.TYPE;
1561 if (type.equals(
"int"))
return Integer.TYPE;
1562 if (type.equals(
"long"))
return Long.TYPE;
1563 if (type.equals(
"float"))
return Float.TYPE;
1564 if (type.equals(
"double"))
return Double.TYPE;
1565 throw new RuntimeException(
"Only primitive types are supported here");
1568 protected void readAccessControl(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1570 final String methodName = tok.nextToken();
1571 final String style = tok.nextToken();
1573 accessControl.put(methodName, access);
1574 }
catch (
final Exception e) {
1575 throw new RuntimeException(
"Error parsing \"AccessControl\" command at line " + lineNo
1576 +
" in file \"" + filename +
"\"", e);
1580 protected void readOpaque(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1583 String cType =
null;
1584 while (tok.hasMoreTokens()) {
1585 if (cType ==
null) {
1586 cType = tok.nextToken();
1588 cType = cType +
" " + tok.nextToken();
1591 if (cType ==
null) {
1592 throw new RuntimeException(
"No C type for \"Opaque\" command at line " + lineNo +
1593 " in file \"" + filename +
"\"");
1597 }
catch (
final Exception e) {
1598 throw new RuntimeException(
"Error parsing \"Opaque\" command at line " + lineNo +
1599 " in file \"" + filename +
"\"", e);
1603 protected void readReturnsOpaque(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1606 final String funcName = tok.nextToken();
1607 returnsOpaqueJType.put(funcName, javaType);
1608 }
catch (
final Exception e) {
1609 throw new RuntimeException(
"Error parsing \"ReturnsOpaque\" command at line " + lineNo +
1610 " in file \"" + filename +
"\"", e);
1614 protected void readReturnsString(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1616 final String name = tok.nextToken();
1617 returnsString.add(name);
1618 }
catch (
final NoSuchElementException e) {
1619 throw new RuntimeException(
"Error parsing \"ReturnsString\" command at line " + lineNo +
1620 " in file \"" + filename +
"\"", e);
1626 final String name = tok.nextToken();
1627 returnsStringOnly.add(name);
1628 }
catch (
final NoSuchElementException e) {
1629 throw new RuntimeException(
"Error parsing \"ReturnsStringOnly\" command at line " + lineNo +
1630 " in file \"" + filename +
"\"", e);
1636 final String functionName = tok.nextToken();
1637 String restOfLine = tok.nextToken(
"\n\r\f");
1638 restOfLine = restOfLine.trim();
1639 returnedArrayLengths.put(functionName, restOfLine);
1640 }
catch (
final NoSuchElementException e) {
1641 throw new RuntimeException(
"Error parsing \"ReturnedArrayLength\" command at line " + lineNo +
1642 " in file \"" + filename +
"\"", e);
1646 protected void readMaxOneElement(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1648 final String name = tok.nextToken();
1649 maxOneElement.add(name);
1650 }
catch (
final NoSuchElementException e) {
1651 throw new RuntimeException(
"Error parsing \"MaxOneElement\" command at line " + lineNo +
1652 " in file \"" + filename +
"\"", e);
1658 final String setFuncName = tok.nextToken();
1659 final int setFuncUserParamIdx = Integer.parseInt(tok.nextToken());
1660 final String cbFuncTypeName = tok.nextToken();
1661 final int cbFuncUserParamIdx = Integer.parseInt(tok.nextToken());
1662 final String userParamClassName;
1663 final String customKeyClassName;
1664 if( tok.hasMoreTokens() ) {
1665 final String s = tok.nextToken();
1666 if( s.length() == 0 || s.equals(
"null") ) {
1667 userParamClassName =
null;
1669 userParamClassName = s;
1671 if( tok.hasMoreTokens() ) {
1672 customKeyClassName = tok.nextToken();
1674 customKeyClassName =
null;
1677 userParamClassName =
null;
1678 customKeyClassName =
null;
1681 userParamClassName, customKeyClassName);
1682 javaCallbackList.add(jcd);
1683 javaCallbackSetFuncToDef.put(setFuncName, jcd);
1684 }
catch (
final NoSuchElementException e) {
1685 throw new RuntimeException(
"Error parsing \"JavaCallbackDef\" command at line " + lineNo +
1686 " in file \"" + filename +
"\"", e);
1692 final String setFuncName = tok.nextToken();
1693 final JavaCallbackDef jcd = javaCallbackSetFuncToDef.get(setFuncName);
1695 throw new IllegalArgumentException(
"JavaCallbackDef '"+setFuncName+
"\' not (yet) defined.");
1700 while( tok.hasMoreTokens() ) {
1701 stok = tok.nextToken();
1702 if( !isInteger(stok) ) {
1705 final int idx = Integer.parseInt(stok);
1707 throw new IllegalArgumentException(
"JavaCallbackKey '"+setFuncName+
"\' SetCallback-ParamIndex "+idx+
" not in range [0..n].");
1709 jcd.setFuncKeyIndices.add( idx );
1713 if(
null == stok ) {
1714 throw new IllegalArgumentException(
"JavaCallbackKey '"+setFuncName+
"\': CallbackFuncType missing.");
1716 if( !stok.equals(jcd.cbFuncTypeName) ) {
1717 throw new IllegalArgumentException(
"JavaCallbackKey '"+setFuncName+
"\': CallbackFuncType '"+stok+
"' not matching JavaCallbackDef: "+jcd);
1721 while( tok.hasMoreTokens() ) {
1722 final int idx = Integer.parseInt(tok.nextToken());
1724 throw new IllegalArgumentException(
"JavaCallbackKey '"+setFuncName+
"\' CallbackFunc-ParamIndex "+idx+
" not in range [0..n].");
1726 jcd.cbFuncKeyIndices.add( idx );
1728 if( jcd.setFuncKeyIndices.size() != jcd.cbFuncKeyIndices.size() ) {
1729 throw new IllegalArgumentException(
"JavaCallbackKey '"+setFuncName+
"\' SetCallback-ParamIndex list count "+jcd.setFuncKeyIndices.toString()+
1730 " != CallbackFunc-ParamIndex count "+jcd.cbFuncKeyIndices.toString());
1732 }
catch (
final NoSuchElementException e) {
1733 throw new RuntimeException(
"Error parsing \"JavaCallbackKey\" command at line " + lineNo +
1734 " in file \"" + filename +
"\"", e);
1737 private static boolean isInteger(
final String s) {
1739 Integer.parseInt(s);
1741 }
catch(
final Exception e) {
1746 protected void readExtendedIntfImplSymbols(
final StringTokenizer tok,
final String filename,
final int lineNo,
final boolean forInterface,
final boolean forImplementation,
final boolean onlyList) {
1748 BufferedReader javaReader;
1750 javaFile =
new File(tok.nextToken());
1751 javaReader =
new BufferedReader(
new FileReader(javaFile));
1752 }
catch (
final FileNotFoundException e) {
1753 throw new RuntimeException(e);
1757 lexer.setFilename(javaFile.getName());
1760 parser.setFilename(javaFile.getName());
1764 }
catch (
final Exception e) {
1765 throw new RuntimeException(e);
1775 extendedIntfSymbolsOnly.addAll(parsedEnumNames);
1776 extendedIntfSymbolsOnly.addAll(parsedFuncNames);
1777 extendedIntfSymbolsOnly.addAll(parsedInnerInterfaces);
1778 extendedIntfSymbolsOnly.addAll(parsedInnerClasses);
1780 extendedIntfSymbolsIgnore.addAll(parsedEnumNames);
1781 extendedIntfSymbolsIgnore.addAll(parsedFuncNames);
1782 extendedIntfSymbolsIgnore.addAll(parsedInnerInterfaces);
1783 extendedIntfSymbolsIgnore.addAll(parsedInnerClasses);
1786 if(forImplementation) {
1788 extendedImplSymbolsOnly.addAll(parsedEnumNames);
1789 extendedImplSymbolsOnly.addAll(parsedFuncNames);
1790 extendedImplSymbolsOnly.addAll(parsedInnerInterfaces);
1791 extendedImplSymbolsOnly.addAll(parsedInnerClasses);
1793 extendedImplSymbolsIgnore.addAll(parsedEnumNames);
1794 extendedImplSymbolsIgnore.addAll(parsedFuncNames);
1795 extendedImplSymbolsIgnore.addAll(parsedInnerInterfaces);
1796 extendedImplSymbolsIgnore.addAll(parsedInnerClasses);
1801 protected void readIgnore(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1803 final String regex = tok.nextToken();
1804 final Pattern pattern = Pattern.compile(regex);
1805 ignores.add(pattern);
1806 ignoreMap.put(regex, pattern);
1808 }
catch (
final NoSuchElementException e) {
1809 throw new RuntimeException(
"Error parsing \"Ignore\" command at line " + lineNo +
1810 " in file \"" + filename +
"\"", e);
1814 protected void readUnignore(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1816 final String regex = tok.nextToken();
1817 Pattern pattern = ignoreMap.get(regex);
1818 ignoreMap.remove(regex);
1819 ignores.remove(pattern);
1824 pattern = Pattern.compile(regex);
1825 unignores.add(pattern);
1828 }
catch (
final NoSuchElementException e) {
1829 throw new RuntimeException(
"Error parsing \"Unignore\" command at line " + lineNo +
1830 " in file \"" + filename +
"\"", e);
1834 protected void readIgnoreNot(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1836 final String regex = tok.nextToken();
1837 ignoreNots.add(Pattern.compile(regex));
1839 }
catch (
final NoSuchElementException e) {
1840 throw new RuntimeException(
"Error parsing \"IgnoreNot\" command at line " + lineNo +
1841 " in file \"" + filename +
"\"", e);
1845 protected void readUnimplemented(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1847 final String regex = tok.nextToken();
1848 unimplemented.add(Pattern.compile(regex));
1849 }
catch (
final NoSuchElementException e) {
1850 throw new RuntimeException(
"Error parsing \"Unimplemented\" command at line " + lineNo +
1851 " in file \"" + filename +
"\"", e);
1855 protected void readIgnoreField(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1857 final String containingStruct = tok.nextToken();
1858 final String name = tok.nextToken();
1859 ignores.add(Pattern.compile(containingStruct +
"\\." + name));
1860 }
catch (
final NoSuchElementException e) {
1861 throw new RuntimeException(
"Error parsing \"IgnoreField\" command at line " + lineNo +
1862 " in file \"" + filename +
"\"", e);
1868 final String name = tok.nextToken();
1869 immutableAccessSymbols.add(name);
1870 }
catch (
final NoSuchElementException e) {
1871 throw new RuntimeException(
"Error parsing \"ImmutableAccess\" command at line " + lineNo +
1872 " in file \"" + filename +
"\"", e);
1878 final String name = tok.nextToken();
1879 manuallyImplement.add(name);
1880 }
catch (
final NoSuchElementException e) {
1881 throw new RuntimeException(
"Error parsing \"ManuallyImplement\" command at line " + lineNo +
1882 " in file \"" + filename +
"\"", e);
1888 final String tokenClassName = tok.nextToken();
1890 final String restOfLine = tok.nextToken(
"\n\r\f");
1892 }
catch (
final NoSuchElementException e) {
1895 }
catch (
final NoSuchElementException e) {
1896 throw new RuntimeException(
"Error parsing \"CustomJavaCode\" command at line " + lineNo +
1897 " in file \"" + filename +
"\"", e);
1906 protected void readCustomCCode(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1908 final String restOfLine = tok.nextToken(
"\n\r\f");
1909 customCCode.add(restOfLine);
1910 }
catch (
final NoSuchElementException e) {
1911 customCCode.add(
"");
1915 protected void readCustomJNICode(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1917 final String tokenClassName = tok.nextToken();
1919 final String restOfLine = tok.nextToken(
"\n\r\f");
1921 }
catch (
final NoSuchElementException e) {
1924 }
catch (
final NoSuchElementException e) {
1925 throw new RuntimeException(
"Error parsing \"CustomJNICode\" command at line " + lineNo +
1926 " in file \"" + filename +
"\"", e);
1935 protected void readMethodJavadoc(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1937 final String tokenClassName = tok.nextToken();
1938 final String restOfLine = tok.nextToken(
"\n\r\f");
1940 }
catch (
final NoSuchElementException e) {
1941 throw new RuntimeException(
"Error parsing \"MethodJavadoc\" command at line " + lineNo +
1942 " in file \"" + filename +
"\"", e);
1950 protected void readClassJavadoc(
final StringTokenizer tok,
final String filename,
final int lineNo) {
1952 final String tokenClassName = tok.nextToken();
1953 final String restOfLine = tok.nextToken(
"\n\r\f");
1955 }
catch (
final NoSuchElementException e) {
1956 throw new RuntimeException(
"Error parsing \"ClassJavadoc\" command at line " + lineNo +
1957 " in file \"" + filename +
"\"", e);
1997 final String methodName = tok.nextToken();
1998 final ArrayList<Integer> argIndices =
new ArrayList<Integer>(2);
1999 while (tok.hasMoreTokens()) {
2000 final Integer idx = Integer.valueOf(tok.nextToken());
2001 argIndices.add(idx);
2004 if (argIndices.size() > 0) {
2005 argumentsAreString.put(methodName, argIndices);
2007 throw new RuntimeException(
"ERROR: Error parsing \"ArgumentIsString\" command at line " + lineNo +
2008 " in file \"" + filename +
"\": directive requires specification of at least 1 index");
2010 }
catch (
final NoSuchElementException e) {
2011 throw new RuntimeException(
2012 "Error parsing \"ArgumentIsString\" command at line " + lineNo +
2013 " in file \"" + filename +
"\"", e);
2019 final String methodName = tok.nextToken();
2021 while (tok.countTokens() >= 2) {
2022 final int lenIdx = Integer.valueOf(tok.nextToken()).intValue();
2023 final int valIdx = Integer.valueOf(tok.nextToken()).intValue();
2026 if( pascalTuples.size() > 0 ) {
2027 argumentsArePascalString.put(methodName, pascalTuples);
2029 }
catch (
final NoSuchElementException e) {
2030 throw new RuntimeException(
2031 "Error parsing \"ArgumentIsPascalString\" command at line " + lineNo +
2032 " in file \"" + filename +
"\"", e);
2036 protected void readStructPackage(
final StringTokenizer tok,
final String filename,
final int lineNo) {
2038 final String
struct = tok.nextToken();
2039 final String pkg = tok.nextToken();
2040 structPackages.put(struct, pkg);
2041 }
catch (
final NoSuchElementException e) {
2042 throw new RuntimeException(
"Error parsing \"StructPackage\" command at line " + lineNo +
2043 " in file \"" + filename +
"\"", e);
2049 final String structName = tok.nextToken();
2050 String restOfLine = tok.nextToken(
"\n\r\f");
2051 restOfLine = restOfLine.trim();
2052 structMachineDataInfoIndex.put(structName, restOfLine);
2053 }
catch (
final NoSuchElementException e) {
2054 throw new RuntimeException(
"Error parsing \"StructMachineDataInfoIndex\" command at line " + lineNo +
2055 " in file \"" + filename +
"\"", e);
2061 final String functionName = tok.nextToken();
2062 String restOfLine = tok.nextToken(
"\n\r\f");
2063 restOfLine = restOfLine.trim();
2064 returnValueCapacities.put(functionName, restOfLine);
2065 }
catch (
final NoSuchElementException e) {
2066 throw new RuntimeException(
"Error parsing \"ReturnValueCapacity\" command at line " + lineNo +
2067 " in file \"" + filename +
"\"", e);
2073 final String functionName = tok.nextToken();
2074 String restOfLine = tok.nextToken(
"\n\r\f");
2075 restOfLine = restOfLine.trim();
2076 returnValueLengths.put(functionName, restOfLine);
2077 }
catch (
final NoSuchElementException e) {
2078 throw new RuntimeException(
"Error parsing \"ReturnValueLength\" command at line " + lineNo +
2079 " in file \"" + filename +
"\"", e);
2085 final String functionName = tok.nextToken();
2086 String restOfLine = tok.nextToken(
"\n\r\f");
2087 restOfLine = restOfLine.trim();
2088 List<String> list = temporaryCVariableDeclarations.get(functionName);
2090 list =
new ArrayList<String>();
2091 temporaryCVariableDeclarations.put(functionName, list);
2093 list.add(restOfLine);
2094 }
catch (
final NoSuchElementException e) {
2095 throw new RuntimeException(
"Error parsing \"TemporaryCVariableDeclaration\" command at line " + lineNo +
2096 " in file \"" + filename +
"\"", e);
2102 final String functionName = tok.nextToken();
2103 String restOfLine = tok.nextToken(
"\n\r\f");
2104 restOfLine = restOfLine.trim();
2105 List<String> list = temporaryCVariableAssignments.get(functionName);
2107 list =
new ArrayList<String>();
2108 temporaryCVariableAssignments.put(functionName, list);
2110 list.add(restOfLine);
2111 }
catch (
final NoSuchElementException e) {
2112 throw new RuntimeException(
"Error parsing \"TemporaryCVariableAssignment\" command at line " + lineNo +
2113 " in file \"" + filename +
"\"", e);
2117 protected void doInclude(
final StringTokenizer tok,
final File file,
final String filename,
final int lineNo)
throws IOException {
2119 final String includedFilename = tok.nextToken();
2120 File includedFile =
new File(includedFilename);
2121 if (!includedFile.isAbsolute()) {
2122 includedFile =
new File(file.getParentFile(), includedFilename);
2124 read(includedFile.getAbsolutePath());
2125 }
catch (
final NoSuchElementException e) {
2126 throw new RuntimeException(
"Error parsing \"Include\" command at line " + lineNo +
2127 " in file \"" + filename +
"\"", e);
2131 protected void doIncludeAs(
final StringTokenizer tok,
final File file,
final String filename,
final int lineNo)
throws IOException {
2133 final StringBuilder linePrefix =
new StringBuilder(128);
2134 while (tok.countTokens() > 1)
2136 linePrefix.append(tok.nextToken());
2137 linePrefix.append(
" ");
2140 final String includedFilename = tok.nextToken();
2141 File includedFile =
new File(includedFilename);
2142 if (!includedFile.isAbsolute()) {
2143 includedFile =
new File(file.getParentFile(), includedFilename);
2145 read(includedFile.getAbsolutePath(), linePrefix.toString());
2146 }
catch (
final NoSuchElementException e) {
2147 throw new RuntimeException(
"Error parsing \"IncludeAs\" command at line " + lineNo +
2148 " in file \"" + filename +
"\"", e);
2152 protected void readExtend(
final StringTokenizer tok,
final String filename,
final int lineNo) {
2154 final String interfaceName = tok.nextToken();
2155 final List<String> intfs = extendedInterfaces(interfaceName);
2156 intfs.add(tok.nextToken());
2157 }
catch (
final NoSuchElementException e) {
2158 throw new RuntimeException(
"Error parsing \"Extends\" command at line " + lineNo +
2159 " in file \"" + filename +
"\": missing expected parameter", e);
2163 protected void readImplements(
final StringTokenizer tok,
final String filename,
final int lineNo) {
2165 final String tokenClassName = tok.nextToken();
2166 final List<String> intfs = implementedInterfaces(tokenClassName);
2167 intfs.add(tok.nextToken());
2168 }
catch (
final NoSuchElementException e) {
2169 throw new RuntimeException(
"Error parsing \"Implements\" command at line " + lineNo +
2170 " in file \"" + filename +
"\": missing expected parameter", e);
2174 protected void readParentClass(
final StringTokenizer tok,
final String filename,
final int lineNo) {
2176 final String tokenClassName = tok.nextToken();
2177 parentClass.put(tokenClassName, tok.nextToken());
2178 }
catch (
final NoSuchElementException e) {
2179 throw new RuntimeException(
"Error parsing \"ParentClass\" command at line " + lineNo +
2180 " in file \"" + filename +
"\": missing expected parameter", e);
2186 final String fromName = tok.nextToken();
2187 final String toName = tok.nextToken();
2188 javaTypeRenames.put(fromName, toName);
2189 }
catch (
final NoSuchElementException e) {
2190 throw new RuntimeException(
"Error parsing \"RenameJavaType\" command at line " + lineNo +
2191 " in file \"" + filename +
"\": missing expected parameter", e);
2197 final String fromName = tok.nextToken();
2198 final String toName = tok.nextToken();
2200 }
catch (
final NoSuchElementException e) {
2201 throw new RuntimeException(
"Error parsing \"RenameJavaSymbol\" command at line " + lineNo +
2202 " in file \"" + filename +
"\": missing expected parameter", e);
2208 final String fromName = tok.nextToken();
2209 final String toName = tok.nextToken();
2211 }
catch (
final NoSuchElementException e) {
2212 throw new RuntimeException(
"Error parsing \"DelegateImplementation\" command at line " + lineNo +
2213 " in file \"" + filename +
"\": missing expected parameter", e);
2219 String methodName = tok.nextToken();
2220 String restOfLine = tok.nextToken(
"\n\r\f");
2221 restOfLine = restOfLine.trim();
2224 final int spaceIdx = restOfLine.indexOf(
' ');
2226 final String descriptor = restOfLine.substring(0, spaceIdx);
2227 restOfLine = restOfLine.substring(spaceIdx + 1, restOfLine.length());
2228 methodName = methodName + descriptor;
2232 }
catch (
final NoSuchElementException e) {
2233 throw new RuntimeException(
"Error parsing \"" +
2234 (prologue ?
"JavaPrologue" :
"JavaEpilogue") +
2235 "\" command at line " + lineNo +
2236 " in file \"" + filename +
"\"", e);
2241 final Map<String, List<String>> codes = (prologue ? javaPrologues : javaEpilogues);
2242 List<String> data = codes.get(methodName);
2244 data =
new ArrayList<String>();
2245 codes.put(methodName, data);
2250 protected void readRangeCheck(
final StringTokenizer tok,
final String filename,
final int lineNo,
final boolean inBytes) {
2252 final String functionName = tok.nextToken();
2253 final int argNum = Integer.parseInt(tok.nextToken());
2254 String restOfLine = tok.nextToken(
"\n\r\f");
2255 restOfLine = restOfLine.trim();
2258 "Buffers.rangeCheck" +
2259 (inBytes ?
"Bytes" :
"") +
2260 "({" + argNum +
"}, " + restOfLine +
");",
2262 }
catch (
final Exception e) {
2263 throw new RuntimeException(
"Error parsing \"RangeCheck" + (inBytes ?
"Bytes" :
"") +
"\" command at line " + lineNo +
2264 " in file \"" + filename +
"\"", e);
2269 String typeName =
null;
2270 int pointerDepth = 0;
2272 while (idx < cType.length() &&
2273 (cType.charAt(idx) !=
' ') &&
2274 (cType.charAt(idx) !=
'*')) {
2277 typeName = cType.substring(0, idx);
2279 while (idx < cType.length()) {
2280 if (cType.charAt(idx) ==
'*') {
2285 return new TypeInfo(typeName, pointerDepth, javaType);
2290 if(
null != superInfo ) {
2291 final TypeInfo res =
new TypeInfo(alias, superInfo.pointerDepth(), superInfo.javaType());
2299 TypeInfo tmp = typeInfoMap.get(info.name());
2301 typeInfoMap.put(info.name(), info);
2304 while (tmp.next() !=
null) {
2310 private static int nextIndexAfterType(
final String s,
int idx) {
2311 final int len = s.length();
2313 final char c = s.charAt(idx);
2315 if (Character.isJavaIdentifierStart(c) ||
2316 Character.isJavaIdentifierPart(c) ||
2319 }
else if (c ==
';') {
2328 private static int nextIndexAfterDescriptor(
final String s,
final int idx) {
2329 final char c = s.charAt(idx);
2339 case 'V':
return (1 + idx);
2340 case 'L':
return nextIndexAfterType(s, idx + 1);
2341 case ')':
return idx;
2352 final int len = s.length();
2353 while ((idx < len) && s.charAt(idx) ==
' ') {
2357 if (idx >= len)
return false;
2358 if (s.charAt(idx++) !=
'(')
return false;
2360 final int nextIdx = nextIndexAfterDescriptor(s, idx);
2364 if (nextIdx == idx) {
2370 final int nextIdx = nextIndexAfterDescriptor(s, idx + 1);
2384 final String cbFuncTypeName;
2385 final String cbSimpleClazzName;
2386 final String cbFQClazzName;
2387 final String staticCBMethodSignature;
2390 final List<Integer> cbFuncKeyIndices;
2391 final int cbFuncUserParamIdx;
2392 final String cbFuncUserParamName;
2393 final Type cbFuncUserParamType;
2395 final boolean cbUserParamIsDefined;
2397 final String setFuncName;
2398 final List<Integer> setFuncKeyIndices;
2399 final int setFuncUserParamIdx;
2400 final String userParamClassName;
2401 final String customKeyClassName;
2402 boolean setFuncProcessed;
2403 int setFuncCBParamIdx;
2404 boolean keyClassEmitted;
2406 public JavaCallbackInfo(
final String cbFuncTypeName,
final String cbSimpleClazzName,
final String cbFQClazzName,
final String staticCBMethodSignature,
2407 final FunctionType cbFuncType,
final MethodBinding cbFuncBinding,
final int cbFuncUserParamIdx,
final List<Integer> cbFuncKeyIndices,
2408 final String setFuncName,
final int setFuncUserParamIdx,
final List<Integer> setFuncKeyIndices,
2409 final String userParamClassName,
final String customKeyClassName) {
2410 this.cbFuncTypeName = cbFuncTypeName;
2411 this.cbSimpleClazzName = cbSimpleClazzName;
2412 this.cbFQClazzName = cbFQClazzName;
2413 this.staticCBMethodSignature = staticCBMethodSignature;
2414 this.cbFuncType = cbFuncType;
2415 this.cbFuncBinding = cbFuncBinding;
2416 this.cbUserParamIsDefined = setFuncUserParamIdx >= 0;
2417 if( cbUserParamIsDefined ) {
2419 Type paramType =
null;
2420 String paramName =
null;
2421 if( 0 <= cbFuncUserParamIdx && cbFuncUserParamIdx < cbFuncType.
getNumArguments() ) {
2425 paramIdx = cbFuncUserParamIdx;
2430 this.cbFuncUserParamIdx = paramIdx;
2431 this.cbFuncUserParamName = paramName;
2432 this.cbFuncUserParamType = paramType;
2434 this.cbFuncUserParamIdx = -1;
2435 this.cbFuncUserParamName =
null;
2436 this.cbFuncUserParamType =
null;
2438 this.cbFuncKeyIndices = cbFuncKeyIndices;
2439 this.setFuncName = setFuncName;
2440 this.setFuncKeyIndices = setFuncKeyIndices;
2441 this.setFuncUserParamIdx = setFuncUserParamIdx;
2442 this.userParamClassName = userParamClassName;
2443 this.customKeyClassName = customKeyClassName;
2444 this.setFuncProcessed =
false;
2445 this.setFuncCBParamIdx = -1;
2446 this.keyClassEmitted =
false;
2448 private void validateKeyIndices(
final FunctionType setFuncType) {
2449 if( this.cbFuncKeyIndices.size() !=
this.setFuncKeyIndices.size() ) {
2450 throw new IllegalArgumentException(
"JavaCallback "+setFuncName+
": Key count mismatch: setFunc "+setFuncKeyIndices.toString()+
2451 " != cbFunc "+cbFuncKeyIndices.toString());
2453 for(
int i=0; i< this.cbFuncKeyIndices.size(); ++i) {
2454 final int cbFuncIdx = this.cbFuncKeyIndices.get(i);
2456 final int setFuncIdx = this.setFuncKeyIndices.get(i);
2459 throw new IllegalArgumentException(
"JavaCallback "+setFuncName+
": Key Type mismatch: setFunc#"+setFuncIdx+
" with "+t2.
toString()+
", cbFunc#"+cbFuncIdx+
" with "+t1.
toString());
2465 if( !setFuncProcessed ) {
2466 if( 0 <= cbParamIdx ) {
2467 setFuncProcessed =
true;
2468 setFuncCBParamIdx = cbParamIdx;
2469 validateKeyIndices(setFuncType);
2471 setFuncCBParamIdx = -1;
2478 return String.format(
"JavaCallbackInfo[cbFunc[%s%s, userParam[defined %b, idx %d, '%s', %s, keys %s], set[%s(ok %b, cbIdx %d, upIdx %d, keys %s], Class[UserParam '%s', Key '%s'], %s]",
2479 cbFuncTypeName, staticCBMethodSignature,
2480 cbUserParamIsDefined, cbFuncUserParamIdx, cbFuncUserParamName, cbUserParamIsDefined ? cbFuncUserParamType.
getSignature(
null).toString() :
null, cbFuncKeyIndices.toString(),
2481 setFuncName, setFuncProcessed, setFuncCBParamIdx, setFuncUserParamIdx,
2482 setFuncKeyIndices.toString(), userParamClassName, customKeyClassName,
2483 cbFuncType.
toString(cbFuncTypeName,
false,
true));
2487 final Map<String, JavaCallbackInfo> setFuncToJavaCallbackMap =
new HashMap<String, JavaCallbackInfo>();
2488 final Set<String> emittedJavaCallbackUserParamClasses =
new HashSet<String>();
2491 final boolean requiresJavaCallbackCode(
final String bindingName) {
2493 return null != jcbi;
Glue code generator for C functions and data structures.
JavaCallback configuration definition (static)
JavaCallback compile time information, produced by JavaEmitter#beginFunctions(TypeDictionary,...
void setFuncProcessed(final FunctionType setFuncType, final int cbParamIdx)
JavaCallbackInfo(final String cbFuncTypeName, final String cbSimpleClazzName, final String cbFQClazzName, final String staticCBMethodSignature, final FunctionType cbFuncType, final MethodBinding cbFuncBinding, final int cbFuncUserParamIdx, final List< Integer > cbFuncKeyIndices, final String setFuncName, final int setFuncUserParamIdx, final List< Integer > setFuncKeyIndices, final String userParamClassName, final String customKeyClassName)
Parses and provides access to the contents of .cfg files for the JavaEmitter.
void readReturnValueLength(final StringTokenizer tok, final String filename, final int lineNo)
List< Integer > stringArguments(final AliasedSymbol symbol)
Returns a list of Integers which are the indices of const char* arguments that should be converted to...
void readCustomJavaCode(final StringTokenizer tok, final String filename, final int lineNo)
String extendedParentClass(final String className)
Returns a List of Strings indicating the interfaces the passed class should declare it implements.
void readOpaque(final StringTokenizer tok, final String filename, final int lineNo)
String implClassName()
Returns the implementation class name parsed from the configuration file.
List< String > customJavaCodeForClass(final String className)
Returns a list of Strings containing user-implemented code for the given Java type name (not fully-qu...
static ASTLocusTag getASTLocusTag(final AliasedSymbol s)
void readUnignore(final StringTokenizer tok, final String filename, final int lineNo)
void readJavaPrologueOrEpilogue(final StringTokenizer tok, final String filename, final int lineNo, final boolean prologue)
List< JavaType.PascalStringElem > pascalStringArgument(final AliasedSymbol symbol)
Returns a list of PascalStringIdx which are tuples of indices of int len, const char* arguments that ...
void readIgnoreField(final StringTokenizer tok, final String filename, final int lineNo)
List< String > temporaryCVariableAssignments(final String functionName)
Returns a List of Strings of expressions containing assignments to temporary C variables in the glue ...
void addTypeInfo(final TypeInfo info)
boolean allStatic()
Returns true if the emission style is AllStatic.
boolean isForceUsingNIOOnly4All()
final boolean shouldIgnoreInImpl_Int(final AliasedSymbol symbol)
void readExtendedIntfImplSymbols(final StringTokenizer tok, final String filename, final int lineNo, final boolean forInterface, final boolean forImplementation, final boolean onlyList)
final void read(final String filename)
Reads the configuration file.
void readStructMachineDataInfoIndex(final StringTokenizer tok, final String filename, final int lineNo)
JavaCallbackDef javaCallbackSetFuncToDef(final AliasedSymbol symbol)
Returns the configured JavaCallback definition mapped to the JavaCallback-Set-Function name.
void readReturnValueCapacity(final StringTokenizer tok, final String filename, final int lineNo)
boolean useNIOOnly(final String functionName)
Returns true if the given function should only create a java.nio variant, and no array variants,...
void readManuallyImplement(final StringTokenizer tok, final String filename, final int lineNo)
boolean returnsString(final AliasedSymbol symbol)
Indicates whether the given function (which returns a char* in C) should be translated as returning a...
List< String > forcedStructs()
Returns, as a List of Strings, the structs for which glue code emission should be forced.
final boolean immutableAccess(final String symbol)
Returns true if the glue code for the given symbol shall produce code for immutable access only.
void readMaxOneElement(final StringTokenizer tok, final String filename, final int lineNo)
void readReturnsOpaque(final StringTokenizer tok, final String filename, final int lineNo)
String nativeOutputDir()
Returns the native code output directory parsed from the configuration file.
List< String > imports()
Returns the list of imports that should be emitted at the top of each .java file.
boolean shouldIgnoreInInterface(final AliasedSymbol symbol)
Returns true if this aliased symbol should be ignored during glue code generation of interfaces and i...
boolean tagNativeBinding()
Returns whether the comment of a native method binding should include a @native tag.
void addJavaSymbolRename(final String origName, final String newName)
Programmatically adds a rename directive for the given symbol.
TypeInfo canonicalNameOpaque(final String canonicalName)
If the given canonicalName should be considered opaque, returns the TypeInfo describing the replaceme...
void readStructPackage(final StringTokenizer tok, final String filename, final int lineNo)
void readImplements(final StringTokenizer tok, final String filename, final int lineNo)
void readDelegateImplementation(final StringTokenizer tok, final String filename, final int lineNo)
void readTemporaryCVariableAssignment(final StringTokenizer tok, final String filename, final int lineNo)
boolean shouldIgnoreInImpl(final AliasedSymbol symbol)
Returns true if this aliased symbol should be ignored during glue code generation of implementation o...
void readJavaCallbackKey(final StringTokenizer tok, final String filename, final int lineNo)
String returnValueLength(final String symbol)
Returns a MessageFormat string of the C expression calculating the length of the array being returned...
String returnedArrayLength(final String symbol)
Returns a MessageFormat string of the Java expression calculating the number of elements in the retur...
String getDelegatedImplementation(final AliasedSymbol symbol)
Returns the RENAMED-IMPL-SYMBOL if the implementation of the glue code of the given function shall be...
void readArgumentIsString(final StringTokenizer tok, final String filename, final int lineNo)
When const char* arguments in the C function prototypes are encountered, the emitter will normally co...
boolean returnsStringOnly(final String functionName)
Indicates whether the given function (which returns a char* in C) should be translated as returning a...
boolean emitInterface()
Returns true if an interface should be emitted during glue code generation.
String className()
Returns the class name parsed from the configuration file.
void dispatch(final String cmd, final StringTokenizer tok, final File file, final String filename, final int lineNo)
static TypeInfo parseTypeInfo(final String cType, final JavaType javaType)
boolean emitImpl()
Returns true if an implementing class should be emitted during glue code generation.
String gluegenRuntimePackage()
Returns the package in which the generated glue code expects to find its run-time helper classes (Buf...
boolean manuallyImplement(final String functionName)
Variant of manuallyImplement(AliasedSymbol), where this method only considers the current-name of the...
boolean maxOneElement(final String symbol)
Indicates whether the given symbol covers no or one single object.
void readReturnsStringOnly(final StringTokenizer tok, final String filename, final int lineNo)
boolean isUnimplemented(final AliasedSymbol symbol)
Returns true if this function should be given a body which throws a run-time exception with an "unimp...
void readClassJavadoc(final StringTokenizer tok, final String filename, final int lineNo)
TypeInfo addTypeInfo(final String alias, final Type superType)
static String canonicalStructFieldSymbol(final String structName, final String fieldName)
Returns the canonical configuration name for a struct field name, i.e.
final boolean shouldIgnoreInInterface_Int(final AliasedSymbol symbol)
String runtimeExceptionType()
Returns the kind of exception to raise if run-time checks fail in the generated code.
void readJavaCallbackDef(final StringTokenizer tok, final String filename, final int lineNo)
List< String > customCCode()
Returns, as a List of Strings, the custom C code to be emitted along with the glue code for the main ...
String returnStructMachineDataInfoIndex(final String structName)
Returns a MessageFormat string of the Java code defining mdIdx, i.e.
EmissionStyle emissionStyle()
Returns the code emission style (constants in JavaEmitter) parsed from the configuration file.
void readParentClass(final StringTokenizer tok, final String filename, final int lineNo)
static< K, V > V oneInMap(final Map< K, V > map, final Set< K > symbols)
static< K > boolean oneInSet(final Set< K > set1, final Set< K > set2)
void readExtend(final StringTokenizer tok, final String filename, final int lineNo)
List< JavaCallbackDef > getJavaCallbackList()
Returns the list of all configured JavaCallback definitions.
void readMethodJavadoc(final StringTokenizer tok, final String filename, final int lineNo)
String implPackageName()
Returns the implementation package name parsed from the configuration file.
void addJavaPrologueOrEpilogue(final String methodName, final String code, final boolean prologue)
void doInclude(final StringTokenizer tok, final File file, final String filename, final int lineNo)
Set< String > getAliasedDocNames(final AliasedSymbol symbol)
Return a set of aliased-name for comment in docs.
MethodAccess accessControl(final String name)
Returns the access control for the given method-name or fully qualified class-name.
List< String > javaPrologueForMethod(final MethodBinding binding, final boolean forImplementingMethodCall, final boolean eraseBufferAndArrayTypes)
Returns a list of Strings which should be emitted as a prologue to the body for the Java-side glue co...
void addUseNIODirectOnly(final String fname)
String readString(final String cmd, final StringTokenizer tok, final String filename, final int lineNo)
final boolean immutableAccess(final AliasedSymbol symbol)
Returns true if the glue code for the given aliased symbol shall produce code for immutable access on...
void doIncludeAs(final StringTokenizer tok, final File file, final String filename, final int lineNo)
JavaType getOpaqueReturnType(final AliasedSymbol symbol)
Returns the opaque JavaType for the given function AliasedSymbol or null if not opaque.
JavaType getOpaqueReturnType(final String functionName)
Variant of getOpaqueReturnType(AliasedSymbol), where this method only considers the current-name of t...
Set< String > getRenamedJavaSymbols(final String aliasedName)
Returns a set of replaced names to the given aliasedName.
String javaOutputDir()
Returns the Java code output directory parsed from the configuration file.
String libraryOnLoadName()
Returns the library basename used to CCodeUnit#emitJNIOnLoadJNIEnvCode(String).
String packageForStruct(final String structName)
Returns the package into which to place the glue code for accessing the specified struct.
List< String > implementedInterfaces(final String className)
Returns a List of Strings indicating the interfaces the passed class should declare it implements.
boolean returnsString(final String functionName)
Indicates whether the given function (which returns a char* in C) should be translated as returning a...
void readUnimplemented(final StringTokenizer tok, final String filename, final int lineNo)
void readTemporaryCVariableDeclaration(final StringTokenizer tok, final String filename, final int lineNo)
void readCustomCCode(final StringTokenizer tok, final String filename, final int lineNo)
Class<?> stringToPrimitiveType(final String type)
void readReturnedArrayLength(final StringTokenizer tok, final String filename, final int lineNo)
void readImmutableAccess(final StringTokenizer tok, final String filename, final int lineNo)
void addMethodJavadoc(final String methodName, final String code)
boolean relaxedEqualSemanticsTest()
Returns whether TypeConfig.SemanticEqualityOp#equalSemantics(TypeConfig.SemanticEqualityOp) shall att...
String unsupportedExceptionType()
Returns the kind of exception to raise if run-time checks fail in the generated code.
String getJavaSymbolRename(final String origName)
Returns a replacement name for this function or definition which should be used as the Java name for ...
void addCustomJNICode(final String className, final String code)
List< String > javaEpilogueForMethod(final MethodBinding binding, final boolean forImplementingMethodCall, final boolean eraseBufferAndArrayTypes)
Returns a list of Strings which should be emitted as an epilogue to the body for the Java-side glue c...
List< String > javadocForMethod(final String methodName)
void addDelegateImplementation(final String origName, final String renamedImpl)
Programmatically adds a delegate implementation directive for the given symbol.
String packageName()
Returns the package name parsed from the configuration file.
String returnValueCapacity(final String functionName)
Returns a MessageFormat string of the C expression calculating the capacity of the java....
String getDelegatedImplementation(final String functionName)
Variant of getDelegatedImplementation(AliasedSymbol), where this method only considers the current-na...
String renameJavaType(final String javaTypeName)
Returns a replacement name for this type, which should be the name of a Java wrapper class for a C st...
void readCustomJNICode(final StringTokenizer tok, final String filename, final int lineNo)
void readRenameJavaSymbol(final StringTokenizer tok, final String filename, final int lineNo)
void readRenameJavaType(final StringTokenizer tok, final String filename, final int lineNo)
List< String > temporaryCVariableDeclarations(final String functionName)
Returns a List of Strings of expressions declaring temporary C variables in the glue code for the spe...
void readIgnore(final StringTokenizer tok, final String filename, final int lineNo)
void readIgnoreNot(final StringTokenizer tok, final String filename, final int lineNo)
TypeInfo typeInfo(Type type)
If this type should be considered opaque, returns the TypeInfo describing the replacement type.
boolean nativeOutputUsesJavaHierarchy()
Returns whether the native code directory structure mirrors the Java hierarchy.
void readReturnsString(final StringTokenizer tok, final String filename, final int lineNo)
static boolean startsWithDescriptor(final String s)
void readRangeCheck(final StringTokenizer tok, final String filename, final int lineNo, final boolean inBytes)
void addClassJavadoc(final String className, final String code)
List< String > customJNICodeForClass(final String className)
Returns a list of Strings containing user-implemented JNI code for the given Java type name (not full...
void setOutputRootDir(final String s)
boolean manuallyImplement(final AliasedSymbol symbol)
Returns true if the glue code for the given aliased function will be manually implemented by the end ...
void addCustomJavaCode(final String className, final String code)
Boolean readBoolean(final String cmd, final StringTokenizer tok, final String filename, final int lineNo)
boolean useNIODirectOnly(final String functionName)
Returns true if the given function should only create a java.nio variant, and no array variants,...
void addUseNIOOnly(final String fname)
final boolean shouldIgnoreInInterface(final String symbol)
Variant of shouldIgnoreInInterface(AliasedSymbol), where this method only considers the current-name ...
void readArgumentIsPascalString(final StringTokenizer tok, final String filename, final int lineNo)
List< String > javadocForClass(final String className)
Returns a list of Strings containing Javadoc documentation for the given Java type name (not fully-qu...
void readAccessControl(final StringTokenizer tok, final String filename, final int lineNo)
List< String > extendedInterfaces(final String interfaceName)
Returns a List of Strings indicating the interfaces the passed interface should declare it extends.
final void read(final String filename, final String linePrefix)
Reads the specified file, treating each line as if it started with the specified string.
Pascal string argument index tuple for length and value.
Describes a java-side representation of a type that is used to represent the same data on both the Ja...
static JavaType createForOpaqueClass(final Class<?> clazz)
Creates a JavaType corresponding to the given opaque Java type.
static LoggerIf getLogger()
Returns the root package logger.
Represents the binding of a C function to a Java method.
String getDescriptor(final boolean forImplementingMethodCall, final boolean eraseBufferAndArrayTypes)
Returns a String containing the descriptor (signature in internal format) of this MethodBinding as it...
String getName()
Returns the FunctionSymbol's current aliased API name.
Static Type config helper binding JavaConfiguration#relaxedEqualSemanticsTest() system wide.
Utility class for handling Opaque directives for JavaEmitter.
void setNext(final TypeInfo info)
String getStructName()
Returns the struct name of this CompoundType, i.e.
Describes a function type, used to model both function declarations and (via PointerType) function po...
String getArgumentName(final int i)
Returns the name of the ith argument.
String toString()
Returns a string representation of this type.
Type getArgumentType(final int i)
Returns the type of the ith argument.
final Type getTargetType()
Helper method to returns the target type of this type, in case another type is being referenced,...
final StringBuilder getSignature(StringBuilder sb)
PointerType asPointer()
Casts this to a PointerType or returns null if not a PointerType.
final String getName()
Returns the name of this type.
int pointerDepth()
Helper method for determining how many pointer indirections this type represents (i....
String toString()
Returns a string representation of this type.
Type getTargetType()
Helper method to returns the target type of this type, in case another type is being referenced,...
final boolean equals(final Object arg)
Equality test for Types inclusive its given name.
final String getDebugString()
final boolean isPointer()
Indicates whether this is a PointerType.
CompoundType asCompound()
Casts this to a CompoundType or returns null if not a CompoundType.
final boolean isCompound()
Indicates whether this is a CompoundType.
Set< String > getParsedEnumNames()
Returns the EnumTypes this HeaderParser processed.
Set< String > getParsedFunctionNames()
Returns the list of FunctionSymbols this HeaderParser has parsed.
final void compilationUnit()
Set< String > getParsedInnerClassesNames()
Returns the list of inner classes this HeaderParser has parsed.
Set< String > getParsedInnerInterfacesNames()
Returns the list of inner interfaces this HeaderParser has parsed.
Access control for emitted Java methods.
Interface tag for ASTLocusTag provider.
boolean isLoggable(Level level)
See Logger#isLoggable(Level).
void log(final Level level, final String msg)
See Logger#log(Level, String).
Supports symbol aliasing, i.e.
Set< String > getAliasedNames()
Return all aliases for this symbol, i.e.
String getName()
Return the current-name, which is the last renamed-name if issued, or the original-name.