Class Parser
java.lang.Object
org.bytedeco.javacpp.tools.Parser
The Parser, just like the Generator, is a mess that is not meant to support the
entirety of C++, but an appropriate subset as used by typical C/C++ header files.
To figure out what that subset is and what the output should be, the idea is to
apply it on as many C/C++ libraries as possible, and patch the code as we go.
At one point in time, when this prototype code appears to have stabilized, we can
start to redesign it in a more meaningful way.
That said, to understand how it is supposed to function in its present state, one can step through the code at runtime: It is quite friendly to debuggers.
Moreover, it relies on Info objects created as part of the execution
of InfoMapper.map(InfoMap). We can understand better how the parsing
is supposed to get accomplished by studying that documentation as well.
To do: - Inherit constructors from helper classes, if possible - etc.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionClasses that have a base class appearing as a key in this map need a downcast constructor.(package private) final String(package private) InfoMap(package private) InfoMap(package private) String(package private) final LoggerJava names of classes recognized as polymorphic.(package private) final Properties(package private) TokenIndexerJava names of classes needing upcast from their subclasses. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddDowncast(String base, Type from, boolean virtual) (package private) Attribute(package private) Attributeattribute(boolean explicit) (package private) Stringbody()(package private) StringConverts Doxygen-like documentation comments placed after identifiers to Javadoc-style.(package private) StringConverts Doxygen-like documentation comments placed before identifiers to Javadoc-style.(package private) StringcommentDoc(String s, int startIndex) Tries to adapt a Doxygen-style documentation comment to Javadoc-style.(package private) static StringconstructorName(String cppName) Constructors have 2 kinds of fully qualified name: the calling name of a constructor, used when calling the constructor, e.g.: NS::CN(int) and the declaration name, used when defining the constructor outside its class or when referencing a constructor with using to inherit constructors of base class.(package private) voidcontainers(Context context, DeclarationList declList) (package private) voiddeclarations(Context context, DeclarationList declList) (package private) Declaratordeclarator(Context context, String defaultName, int infoNumber, boolean useDefaults, int varNumber, boolean arrayAsPointer, boolean pointerAsArray) (package private) static String(package private) String(package private) booleanenumeration(Context context, DeclarationList declList) (package private) booleanextern(Context context, DeclarationList declList) (package private) booleanfunction(Context context, DeclarationList declList) (package private) TypefunctionAfter(Context context, Declaration decl, Declarator dcl, Type type) Parse function declaration or definition after parameters: const, attributes, trailing type, pure virtual functions.(package private) booleangroup(Context context, DeclarationList declList) (package private) static StringincorporateConstAnnotation(String annotations, int constValueIndex, boolean constValue) (package private) booleanmacro(Context context, DeclarationList declList) (package private) booleannamespace(Context context, DeclarationList declList) private StringRead and return the operator following an operator keyword: any ofnew, delete, + - * / % ^ & | ~ ! = < > += -= *= /= %= ^= &= |= << >> >>= <<= == != <= >= <=>(since C++20) && || ++ -- , ->* -> ( ) [ ]taking care of template arguments, if any.(package private) Parametersparameters(Context context, int infoNumber, boolean useDefaults) File[]File[](package private) voidparse(Context context, DeclarationList declList, String[] includePath, String include, boolean isCFile) (package private) static String(package private) TemplateMap(package private) Type[]templateArguments(Context context) (package private) String(package private) Type(package private) Type(package private) booleantypedef(Context context, DeclarationList declList) (package private) String(package private) static StringupcastMethodName(String javaName) (package private) booleanusing(Context context, DeclarationList declList) (package private) booleanvariable(Context context, DeclarationList declList)
-
Field Details
-
logger
-
properties
-
encoding
-
infoMap
InfoMap infoMap -
leafInfoMap
InfoMap leafInfoMap -
tokens
TokenIndexer tokens -
lineSeparator
String lineSeparator -
upcasts
-
downcasts
-
polymorphicClasses
-
-
Constructor Details
-
Parser
-
Parser
-
Parser
-
-
Method Details
-
addDowncast
-
removeAnnotations
-
desugarVarargs
-
upcastMethodName
-
constructorName
Constructors have 2 kinds of fully qualified name: the calling name of a constructor, used when calling the constructor, e.g.: NS::CN(int) and the declaration name, used when defining the constructor outside its class or when referencing a constructor with using to inherit constructors of base class. NS::CN::CN(int) Declarator.cppName contains the calling name, and this method returns the declaration name. Keys in info map should use the declaration name, because the calling name cannot specify arguments in case of constructor templates, and to avoid confusion between classes and constructors info. -
translate
-
containers
- Throws:
ParserException
-
template
- Throws:
ParserException
-
templateArguments
- Throws:
ParserException
-
operator
Read and return the operator following an operator keyword: any ofnew, delete, + - * / % ^ & | ~ ! = < > += -= *= /= %= ^= &= |= << >> >>= <<= == != <= >= <=>(since C++20) && || ++ -- , ->* -> ( ) [ ]taking care of template arguments, if any.- Throws:
ParserException
-
type
- Throws:
ParserException
-
type
- Throws:
ParserException
-
declarator
Declarator declarator(Context context, String defaultName, int infoNumber, boolean useDefaults, int varNumber, boolean arrayAsPointer, boolean pointerAsArray) throws ParserException - Throws:
ParserException
-
commentDoc
-
commentBefore
String commentBefore()Converts Doxygen-like documentation comments placed before identifiers to Javadoc-style. Also leaves as is non-documentation comments. -
commentAfter
String commentAfter()Converts Doxygen-like documentation comments placed after identifiers to Javadoc-style. -
attribute
Attribute attribute() -
attribute
-
body
- Throws:
ParserException
-
parameters
- Throws:
ParserException
-
incorporateConstAnnotation
-
function
- Throws:
ParserException
-
functionAfter
Type functionAfter(Context context, Declaration decl, Declarator dcl, Type type) throws ParserException Parse function declaration or definition after parameters: const, attributes, trailing type, pure virtual functions. Updates dcl, decl and/or type accordingly.- Throws:
ParserException
-
variable
- Throws:
ParserException
-
macro
- Throws:
ParserException
-
typedef
- Throws:
ParserException
-
using
- Throws:
ParserException
-
downcast
-
upcast
-
group
- Throws:
ParserException
-
enumeration
- Throws:
ParserException
-
namespace
- Throws:
ParserException
-
extern
- Throws:
ParserException
-
declarations
- Throws:
ParserException
-
parse
void parse(Context context, DeclarationList declList, String[] includePath, String include, boolean isCFile) throws IOException, ParserException - Throws:
IOExceptionParserException
-
parse
public File[] parse(String outputDirectory, String[] classPath, Class cls) throws IOException, ParserException - Throws:
IOExceptionParserException
-
parse
public File[] parse(File outputDirectory, String[] classPath, Class cls) throws IOException, ParserException - Throws:
IOExceptionParserException
-