Package org.bytedeco.javacpp.tools
Class Generator
- java.lang.Object
-
- org.bytedeco.javacpp.tools.Generator
-
public class Generator extends Object
The Generator is where all the C++ source code that we need gets generated. It has not been designed in any meaningful way since the requirements were not well understood. It is basically a prototype and is really quite a mess. Now that we understand better what we need, it could use some refactoring.When attempting to understand what the Generator does, try to run experiments and inspect the generated code: It is quite readable.
Moreover, although Generator is the one ultimately doing something with the various annotations it relies on, it was easier to describe the behavior its meant to have with them as part of the documentation of the annotations, so we can refer to them to understand more about how Generator should work:
- Author:
- Samuel Audet
- See Also:
Adapter,Allocator,ArrayAllocator,ByPtr,ByPtrPtr,ByPtrRef,ByRef,ByVal,Cast,Const,Convention,CriticalRegion,Function,Index,MemberGetter,MemberSetter,Name,Namespace,NoDeallocator,NoException,NoOffset,Opaque,Platform,Raw,ValueGetter,ValueSetter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classGenerator.BooleanEnum(package private) static classGenerator.ByteEnum(package private) static classGenerator.IntEnum(package private) static classGenerator.LongEnum(package private) static classGenerator.ShortEnum
-
Field Summary
Fields Modifier and Type Field Description (package private) booleanaccessesEnums(package private) Map<Method,MethodInformation>annotationCache(package private) IndexedSet<Class>arrayDeallocators(package private) static List<Class>baseClasses(package private) Map<String,String>callbacks(package private) IndexedSet<Class>deallocators(package private) Stringencoding(package private) IndexedSet<Class>functions(package private) IndexedSet<Class>jclasses(package private) static StringJNI_VERSION(package private) PrintWriterjniConfigOut(package private) Loggerlogger(package private) booleanmayThrowExceptions(package private) Map<Class,Set<String>>members(package private) PrintWriterout(package private) PrintWriterout2(package private) booleanpassesStrings(package private) Propertiesproperties(package private) PrintWriterreflectConfigOut(package private) booleanusesAdapters(package private) Map<Class,Set<String>>virtualFunctions(package private) Map<Class,Set<String>>virtualMembers
-
Constructor Summary
Constructors Constructor Description Generator(Logger logger, Properties properties)Generator(Logger logger, Properties properties, String encoding)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) AdapterInformationadapterInformation(boolean out, String valueTypeName, Annotation... annotations)(package private) AdapterInformationadapterInformation(boolean out, MethodInformation methodInfo, int j)(package private) static Allocatorallocator(Class<?> cls, Method method)(package private) static intallocatorMax(Class<?> cls, Method method)(package private) static booleanasUtf16(Annotation[] annotations)(package private) static booleanasUtf16(MethodInformation methodInfo, int j)(package private) Annotationbehavior(Annotation... annotations)(package private) Annotationby(Annotation... annotations)(package private) Annotationby(MethodInformation methodInfo, int j)(package private) voidcall(MethodInformation methodInfo, String returnPrefix, boolean secondCall)(package private) voidcallback(Class<?> cls, Method callbackMethod, String callbackName, int allocatorMax, boolean needDefinition, MethodInformation methodInfo)(package private) voidcallbackAllocator(Class<?> cls, String callbackName, int allocatorMax)(package private) Stringcast(Class<?> type, Annotation... annotations)(package private) Stringcast(MethodInformation methodInfo, int j)(package private) booleanclasses(boolean handleExceptions, boolean defineAdapters, boolean convertStrings, boolean declareEnums, String loadSuffix, String baseLoadSuffix, String classPath, Class<?>... classes)(package private) static booleanconstFunction(Class<?> classType, Method functionMethod)(package private) static StringconstValueTypeName(String... typeName)(package private) String[]cppAnnotationTypeName(Class<?> type, Annotation... annotations)(package private) String[]cppCastTypeName(Class<?> type, Annotation... annotations)(package private) String[]cppFunctionTypeName(Method... functionMethods)(package private) static StringcppScopeName(Class<?> type)(package private) static StringcppScopeName(MethodInformation methodInfo)(package private) String[]cppTypeName(Class<?> type)(package private) String[]cppTypeName(Class<?> type, Annotation[] annotations)(package private) String[]cppTypeName(MethodInformation methodInfo, int j)(package private) static StringcreateString(String ptr, String adapter, boolean asUtf16)(package private) static booleancriticalRegion(Class<?> cls, Method method)(package private) StringenumValueType(Class<?> type)(package private) static StringfunctionClassName(Class<?> cls)(package private) static Method[]functionMethods(Class<?> cls, Method[] methods, boolean[] callbackAllocators)booleangenerate(String sourceFilename, String jniConfigFilename, String reflectConfigFilename, String headerFilename, String loadSuffix, String baseLoadSuffix, String classPath, Class<?>... classes)(package private) static StringgetStringData(String str, boolean asUtf16)(package private) static StringjniTypeName(Class type)(package private) static Stringmangle(String name)(package private) MethodInformationmethodInformation(Method method)(package private) booleanmethods(Class<?> cls)(package private) static booleannoexceptFunction(Class<?> classType, Method functionMethod)(package private) static booleannoException(Class<?> cls, Method method)(package private) voidparametersAfter(MethodInformation methodInfo)(package private) voidparametersBefore(MethodInformation methodInfo)(package private) static StringreleaseStringData(String str, String ptr, boolean asUtf16)(package private) voidreturnAfter(MethodInformation methodInfo)(package private) StringreturnBefore(MethodInformation methodInfo)(package private) static Stringsignature(Class... types)(package private) static StringvalueTypeName(String... typeName)
-
-
-
Field Detail
-
JNI_VERSION
static final String JNI_VERSION
- See Also:
- Constant Field Values
-
logger
final Logger logger
-
properties
final Properties properties
-
encoding
final String encoding
-
out
PrintWriter out
-
out2
PrintWriter out2
-
jniConfigOut
PrintWriter jniConfigOut
-
reflectConfigOut
PrintWriter reflectConfigOut
-
functions
IndexedSet<Class> functions
-
deallocators
IndexedSet<Class> deallocators
-
arrayDeallocators
IndexedSet<Class> arrayDeallocators
-
jclasses
IndexedSet<Class> jclasses
-
annotationCache
Map<Method,MethodInformation> annotationCache
-
mayThrowExceptions
boolean mayThrowExceptions
-
usesAdapters
boolean usesAdapters
-
passesStrings
boolean passesStrings
-
accessesEnums
boolean accessesEnums
-
-
Constructor Detail
-
Generator
public Generator(Logger logger, Properties properties)
-
Generator
public Generator(Logger logger, Properties properties, String encoding)
-
-
Method Detail
-
generate
public boolean generate(String sourceFilename, String jniConfigFilename, String reflectConfigFilename, String headerFilename, String loadSuffix, String baseLoadSuffix, String classPath, Class<?>... classes) throws IOException
- Throws:
IOException
-
classes
boolean classes(boolean handleExceptions, boolean defineAdapters, boolean convertStrings, boolean declareEnums, String loadSuffix, String baseLoadSuffix, String classPath, Class<?>... classes)
-
methods
boolean methods(Class<?> cls)
-
parametersBefore
void parametersBefore(MethodInformation methodInfo)
-
returnBefore
String returnBefore(MethodInformation methodInfo)
-
call
void call(MethodInformation methodInfo, String returnPrefix, boolean secondCall)
-
returnAfter
void returnAfter(MethodInformation methodInfo)
-
parametersAfter
void parametersAfter(MethodInformation methodInfo)
-
callback
void callback(Class<?> cls, Method callbackMethod, String callbackName, int allocatorMax, boolean needDefinition, MethodInformation methodInfo)
-
functionMethods
static Method[] functionMethods(Class<?> cls, Method[] methods, boolean[] callbackAllocators)
-
methodInformation
MethodInformation methodInformation(Method method)
-
adapterInformation
AdapterInformation adapterInformation(boolean out, MethodInformation methodInfo, int j)
-
adapterInformation
AdapterInformation adapterInformation(boolean out, String valueTypeName, Annotation... annotations)
-
cast
String cast(MethodInformation methodInfo, int j)
-
cast
String cast(Class<?> type, Annotation... annotations)
-
by
Annotation by(MethodInformation methodInfo, int j)
-
by
Annotation by(Annotation... annotations)
-
behavior
Annotation behavior(Annotation... annotations)
-
asUtf16
static boolean asUtf16(MethodInformation methodInfo, int j)
-
asUtf16
static boolean asUtf16(Annotation[] annotations)
-
cppAnnotationTypeName
String[] cppAnnotationTypeName(Class<?> type, Annotation... annotations)
-
cppCastTypeName
String[] cppCastTypeName(Class<?> type, Annotation... annotations)
-
cppTypeName
String[] cppTypeName(MethodInformation methodInfo, int j)
-
cppTypeName
String[] cppTypeName(Class<?> type, Annotation[] annotations)
-
cppScopeName
static String cppScopeName(MethodInformation methodInfo)
-
-