Package builder
Class FunctionsGenerator
java.lang.Object
builder.FunctionsGenerator
Class used to generate the functions from the MEOS library.
Run with directly with java through the main class
- Since:
- 27/06/2023
- Author:
- Killian Monnier and Nidhal Mareghni
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Path
Path of the file generated byFunctionsExtractor
.private final Path
Path of the file generated byFunctionsExtractor
.Types dictionary.private final Path
Path of the file generated by this class. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuildConversionTypedefs
(String filePath) Build the dictionary of typedef conversion.Build the dictionary of conversion types.Builds the type modification array.static int
countOccurrences
(String text, String pattern) utility function to count the number if occurences of pointer, pointer[] and pointer[][]private StringBuilder
generateClass
(StringBuilder functionsBuilder, StringBuilder interfaceBuilder) Used to generate the class of functions.generateConversionProcess
(String signature) Produce the process of adding code to handle conversion of certain types for a function.private StringBuilder
generateFunctions
(String filePath, boolean performTypesConversion) Generation of functions with their conversion types, typedef conversion types and equivalent types.private StringBuilder
generateInterface
(StringBuilder functionsBuilder) Generation of the interface.Produce the returning process for a functiongetFunctionTypes
(String signature) Gives the types of the function's parameters and return from a line corresponding to the format of a function.getUnsupportedTypes
(String signature, Map<String, String> types) Check unsupported types.static void
Launch process of extraction.private static String
performTypeConversion
(String line) Processes the rows to generate the functions.
-
Field Details
-
C_functionsPath
Path of the file generated byFunctionsExtractor
. Contains a list of functions signature. -
C_typesPath
Path of the file generated byFunctionsExtractor
. Contains a list of types definition. -
functionsFilePath
Path of the file generated by this class. -
equivalentTypes
Types dictionary. Contains the C types and there equivalent in Java -
conversionTypes
-
conversionTypedefs
-
unsupportedEquivalentTypes
-
unsupportedConversionTypedefs
-
unsupportedConversionTypes
-
-
Constructor Details
-
FunctionsGenerator
Constructor ofFunctionsExtractor
.- Throws:
URISyntaxException
- thrown when resources not found
-
-
Method Details
-
getFunctionTypes
Gives the types of the function's parameters and return from a line corresponding to the format of a function.- Parameters:
signature
- function signature- Returns:
- types list
-
main
Launch process of extraction.- Parameters:
args
- arguments- Throws:
URISyntaxException
- thrown when resources not found
-
performTypeConversion
Processes the rows to generate the functions.- Parameters:
line
- the line corresponding to a function- Returns:
- the processed line
-
buildEquivalentTypes
Builds the type modification array.Key: old type in C or modified Value: new type in Java
- Returns:
- type dictionary
-
buildConversionTypes
Build the dictionary of conversion types.Key: old type in C or modified Value: new type in Java
- Returns:
- types dictionary
-
getUnsupportedTypes
Check unsupported types.- Parameters:
signature
- function signature
-
buildConversionTypedefs
Build the dictionary of typedef conversion.Key: old type in C or modified Value: new type in Java
- Parameters:
filePath
- file path of C typedefs- Returns:
- types dictionary
-
generateConversionProcess
Produce the process of adding code to handle conversion of certain types for a function. -
countOccurrences
utility function to count the number if occurences of pointer, pointer[] and pointer[][] -
generateReturnProcess
private List<String> generateReturnProcess(String signature, List<Pair<String, String>> typesNamesList) Produce the returning process for a function- Parameters:
signature
- function signaturetypesNamesList
- list of types names to change it in the calling of the equivalent interface function- Returns:
- the returning process
-
generateClass
Used to generate the class of functions.- Parameters:
functionsBuilder
- builder of functionsinterfaceBuilder
- interface builder- Returns:
- the class builder
-
generateInterface
Generation of the interface.- Parameters:
functionsBuilder
- builder of functions- Returns:
- the interface builder
-
generateFunctions
Generation of functions with their conversion types, typedef conversion types and equivalent types.- Parameters:
filePath
- file path of C functionsperformTypesConversion
- true if it needs to perform a types conversion usingconversionTypes
- Returns:
- the function builder
-