jwrapper -
Generator of Nit extern classes to wrap Java APIs.
Description
jwrapper automates wrapping Java classes so they can be accessed from Nit code. It generates Nit extern classes by analyzing Java class files.
jwrapper reuse Nit types of already wrapped Java classes by searching in the lib/java
and lib/android
folders in the Nit repository. It won't wrap a class that are already is those folders.
Installation
jwrapper is designed to be installed from the contrib
directory of Nit repository. (http://www.nitlanguage.org)
To initiate installation process, use make
in the contrib/jwrapper
directory.
jwrapper relies on nitcc
that will be automatically compiled from contrib/nitcc
.
Usage
The jwrapper binary can be found under contrib/jwrapper/bin
directory.
jwrapper uses grep
to find existing libraries, make sure that the environment variable NIT_DIR
is properly set to your Nit root directory.
jwrapper uses javap
to extract data from .class files, the JDK7 or higher has to be installed and must be in your $PATH
. (Older versions of javap
do not show generic signatures)
Usage :
jwrapper [OPTIONS] JAVA_CLASS_FILE NIT_OUTPUT_FILE
The options are :
-a, --with-attributes
- It enables extern class attributes generation. For each public attribute, there'll be a Nit attribute of the corresponding type.
-c, --comment
- When a method contains at least one unknown type, the code generator will comment the whole method and let the client manage it. Unknown types are types that doesn't have an equivalent in Nit as of yet.
-w, --wrap
- A minimalistic extern class will be created for each unknown type (this is the default behaviour)
-h, --help
- Print the help message
Can't use both -c and -w together, either you comment unknown types or you wrap them.
Content
- jwrapper: Generator of Nit extern classes to wrap Java APIs. (contrib/jwrapper)
- src (contrib/jwrapper/src)
- code_generator: Services to generate extern class
in "Java"
(contrib/jwrapper/src/code_generator.nit) - javap_lexer: Lexer generated by nitcc for the grammar javap (contrib/jwrapper/src/javap_lexer.nit)
- javap_parser: Parser generated by nitcc for the grammar javap (contrib/jwrapper/src/javap_parser.nit)
- javap_test_parser: Standalone parser tester for the language javap (contrib/jwrapper/src/javap_test_parser.nit)
- javap_visitor: Uses a visitor to extract data from the javap output AST (contrib/jwrapper/src/javap_visitor.nit)
- jtype_converter: Services to convert java type to nit type and get casts if needed (contrib/jwrapper/src/jtype_converter.nit)
- jwrapper: jwrapper wraps Java classes in extern Nit classes (contrib/jwrapper/src/jwrapper.nit)
- model: Model of the parsed Java classes and their corresponding Nit types (contrib/jwrapper/src/model.nit)
- code_generator: Services to generate extern class
- src (contrib/jwrapper/src)