Author: | Dave Kuhlman |
---|---|
Address: | dkuhlman@rexx.com http://www.rexx.com/~dkuhlman |
Revision: | 1.0a |
Date: | June 24, 2004 |
Copyright: | Copyright (c) 2004 Dave Kuhlman. This documentation is covered by The MIT License: http://www.opensource.org/licenses/mit-license. |
Abstract
This document describes generate_wrappers.py: a python script that generates files for Python wrappers for Java a class. This facility uses and requires gcj, libgcj, and CNI.
generate_wrappers.py generates support files that enable Python to use the classes and methods in a Java source code file.
This facility requires and uses gcj, "The GNU Compiler for the Java Programming Language". It can be used only on platforms that support gcj, gcjh, and libgcj.
The basic strategy is the following:
generate_wrappers.py helps you by generating some of the files you need and by generating a Makefile that generates others. But, you will need to write the C/C++ adapter classes, methods, and functions by hand yourself. And, this will require that you know enough CNI to do so.
The development strategy supported by generate_wrappers.py only works on the platforms supported by gcj and libgcj. See the following for a list of supported platforms: http://gcc.gnu.org/java/status.html.
In order to do development with generate_wrappers.py, you must have the following installed:
Limitation -- I'm not too sure about this, but I believe that this solution limits you to the sub-set of the JDK class libraries that are supported by gcj and libgcj. For more on this, see: http://gcc.gnu.org/java/faq.html#2_1.
You can find generate_wrappers.py here: http://www.rexx.com/~dkuhlman/generate_wrappers-1.0a.tar.gz.
There is a simple example of the use of generate_wrappers.py in the distribution under the Examples directory. See the README file included with the example.
Run generate_wrappers.py from the command line. Give it the base name of your Java class file. For example, if your Java class is in a file named "myclass.java", then you might run the following:
$ python generate_wrappers.py myclass
Here is the usage information for generate_wrappers.py:
/w1/Java/Wrapper_generator [34] ./generate_wrappers.py --help usage: python generate_wrappers.py [options] <base_file_name> example: python generate_wrappers.py my_java_class_file options: -h, --help show this help message and exit -v, --verbose produce verbose output -f, --force force overwrite of files. Do not ask. -p, --python-impl generate empty implementation files
Add (and later modify as necessary) your adapter code. When you run generate_wrappers.py, it prints out a message telling you where (in which files) to add your adapter code.
Run make to generate and compile additional code.
Run Python to test your code.
Repeat steps 2 through 4 as necessary.
Python: The Python home page.
gcj: The GNU Compiler for the Javatm Programming Language
libgcj: The libgcj home page
Java Technology: The Sun Java support site
SWIG: More information about SWIG, the software wrapper interface generator.