使用 SWIG 實現 Java 調用 C++ DLL

來源:互聯網
上載者:User

http://swig.sourceforge.net/

Welcome to SWIG

[ Chinese ]

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of languages including common scripting languages such as Perl, PHP, Python, Tcl and Ruby. The list of supported languages also includes non-scripting languages such as C#, Common Lisp (CLISP, Allegro CL, CFFI, UFFI), Java, Lua, Modula-3, OCAML, Octave and R. Also several interpreted and compiled Scheme implementations (Guile, MzScheme, Chicken) are supported. SWIG is most commonly used to create high-level interpreted or compiled programming environments, user interfaces, and as a tool for testing and prototyping C/C++ software. SWIG can also export its parse tree in the form of XML and Lisp s-expressions. SWIG may be freely used, distributed, and modified for commercial and non-commercial use.

  • Download the latest version.
  • Documentation, papers, and presentations
  • Features.
  • Mailing Lists
  • Bug tracking
  • SwigWiki!
Recent News
2009/09/23 - SWIG's Second Summer of code
SWIG is a programmer's tool designed to make it easier to use C and C++ code from other popular programming languages such as Python, Perl, Ruby, PHP, Java, and C#. 2009 was SWIG's second Summer of Code, and this year we mentored five projects related to SWIG. All five students were very active over the summer period and produced some great new features. In no particular order:

Matev啪 Jekovec has been busy working at the coal face of SWIG to add support for C++0x, the forthcoming C++ standard. Matev啪 has managed to achieve close to full support for C++0x. The C++0x Wikipaedia article http://en.wikipedia.org/wiki/C%2B%2B0x details the numerous planned new C++0x features and Matev啪 has put together a SWIG C++0x page (http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2009-matevz/Doc/Manual/Cpp0x.html) documenting the new SWIG support for each of these. In summary the enhanced C++ language can now be parsed by SWIG, which in itself is a great step. There is much more than just this though, as most of the information parsed is used to create useful wrappers of C++0x code. The work can be tried out on the C++0x branch http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2009-matevz which should be merged fairly soon into a forthcoming release.

Miklos Vajna has been working on SWIG's PHP support to implement an advanced SWIG feature already supported for most other target languages, but not PHP. The feature is called "directors" and allows cross-language polymorphism - wrapped C++ classes can be subclassed in PHP and virtual method calls work in the natural way, whether they're made from PHP or C++ code. You can read more in the new PHP Director documentation http://www.swig.org/Doc1.3/Php.html#Php_nn3 . Miklos made such great progress that we were able to merge this support into SWIG 1.3.40, which was released even before the Summer of Code finished. Miklos also spent some time working on improving SWIG's testsuite for PHP, and fixing bugs in the PHP support.

Ashish Sharma spent the summer adding support for Objective-C as a new target language. Objective-C is a major language on the Mac OS X platform. This means that now SWIG can be used to generate Objective-C wrappers over C++ code. In particular the wrappers include proxy classes, which preserve the class hierarchy from the C++ code. Ultimately this means that from the user's perspective, proxy objects look no different to objects originally written in Objective-C. Adding a new target language is quite a considerable task and Ashish is keen to add plenty more improvements over the coming months. Ashish's work is in Subversion and can be accessed in the ashishs99 branch http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2009-ashishs99 .

Baozeng Ding has also added a new target language, in this case for the Scilab language, a free numerical computing package. He has coded up support for all the C features: variables, functions, constants, enums, structs, unions, pointers and arrays and also intends to develop it further in the near future. Documentation for SWIG and Scilab can be viewed online direct from Baozeng's Subversion branch http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2009-sploving/Doc/Manual/Scilab.html .

Kosei Moriyama has been working on Perl bindings for the Xapian library using SWIG, to replace some existing bindings implemented by hand. He's achieved almost complete compatibility with the API of the existing bindings (the only real omission is callbacks which are waiting for completion of director support for Perl in SWIG). He has also wrapped features which weren't previously accessible from Perl. You can view Kosei's work online in his Subversion branch http://trac.xapian.org/browser/branches/gsoc2009-kosei .

Finally, many thanks to Google for sponsoring the summer of code and a special thanks for all the hard work done by the students, mentors and Olly Betts, the co-administrator. (1 comments)

 

 

2009/08/18 - SWIG-1.3.40 released
SWIG-1.3.40 has been release. A summary of changes is as follows:

- SWIG now supports directors for PHP.
- PHP support improved in general.
- Octave 3.2 support added.
- Various bug fixes/enhancements for Allegrocl, C#, Java, Octave, Perl, Python, Ruby and Tcl.
- Other generic fixes and minor new features. (0 comments)

 

 

2009/04/21 - Summer of code 2009 accepted projects
The students accepted into the Google Summer of Code have now been announced. SWIG has been allocated five student slots by Google and we have chosen the following five projects/students which will be developed over the next four months:

"Add support for Scilab language" - Baozeng Ding
"C++0x support for Swig" - Matevz Jekovec
"Implement Perl binding for Xapian using SWIG" - Kosei MORIYAMA
"Objective C Wrapper Generator over C++ using SWIG" - Ashish Sharma
"Director support for PHP" - Miklos Vajna

An abstract for each project is available at http://socghop.appspot.com/org/home/google/gsoc2009/swig

Congratulations to Baozeng, Matevz, Kosei, Ashish and Miklos, we set some fairly high standards for acceptance this year and you have all done well to meet these standards. We hope that your quality proposals will result in useful enhancements by the end of the summer.

For anyone interested in any of these projects, you are welcome to follow the development of them on the swig-devel mailing list - http://www.swig.org/mail.html . Also feel free to drop by our IRC channel to discuss or just say hello - #swig-gsoc on irc.freenode.net.

William and Olly
SWIG Summer of Code administrators 2009 (0 comments)

 

 

2009/03/21 - SWIG-1.3.39 released
SWIG-1.3.39 has been release. A summary of changes is shown below.

- Some new small feature enhancements.
- Improved C# std::vector wrappers.
- Bug fixes: mainly Python, but also Perl, MzScheme, CFFI, Allegrocl and Ruby (0 comments)

 

 

2009/03/19 - SWIG participating in Summer of Code 2009
We are excited to announce that SWIG has been accepted onto the Google Summer of Code program for the second year running. This is a chance for SWIG to be enhanced in any way that you would like it to.

The Summer of Code program is designed to get new people involved in free/open-source software and get paid for it. Either become a student and code up the changes or if you have an interest in a particular feature being implemented, become a mentor and get paid for looking after a student. The ideas page at http://code.google.com/p/swig-gsoc/wiki/ProjectIdeas contains some suggestions for SWIG, but any reasonable suggestions will be considered. Please chat to us on IRC at #swig-gsoc on irc.freenode.net or email us on the mailing lists. See http://socghop.appspot.com/ for further general information. (0 comments)

 

 

2009/02/01 - SWIG-1.3.38 released
SWIG-1.3.38 has been released. It contains an output directory regression fix and other minor bug fixes. (2 comments)

 

 

2009/01/15 - SWIG: 1.3.37 released
SWIG is a software development tool that reads C/C++ header files and generates wrapper code to make C/C++ code accessible from other languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, C#, Modula-3, R, Octave and Scheme & Lisp variants.

Apart from the usual round of bug fixes and minor new features there are a couple of big new features in this release. The main changes are:

- Python 3 support added
- SWIG now ships with a version of ccache that can be used with SWIG. This enables the files generated by SWIG to be cached so that repeated use of SWIG on unchanged input files speeds up builds quite considerably.
- PHP 4 support removed and PHP support improved in general
- Improved C# array support
- Numerous Allegro CL improvements (2 comments)

 

 

2008/10/08 - SWIG's First Summer of Code
SWIG is a programmers tool for semi-automating the calls to C or C++ code from almost any other programming language. The idea is to feed C/C++ header files into SWIG and SWIG then generates the 'glue' code so that your C/C++ library can be used from another language such as Python, Java, C#, Ruby, Perl etc. In fact there are implementations for supporting over 20 different of these target languages. The summer of code students have had a productive summer and have extended the number of languages and features supported in SWIG's first Google Summer of Code.

Haoyu Bai has added support for the upcoming Python 3 release. Python is the most popular target language amongst SWIG users and no doubt this addition will be much appreciated by those who are thinking of upgrading to Python 3. Also Haoyu has provided new Python 3 features which make coding faster and simpler when using Python extension code. The main features added are function annotations, buffer interfaces and abstract base classes and are outlined in more detail here: http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-bhy/Doc/Manual/Python.html#Python_python3support

Jan Jezabek has added a new 'language' module providing Windows Component Object Model (COM) support. This new module makes it possible for any COM enabled language to easily call into C or C++ libraries. The COM module in SWIG is more powerful than most as it ultimately provides support for more than one language as there are numerous languages that can call into COM libraries. Compiled languages such as Visual Basic and scripting languages, such as JScript, VBA and VBScript that can run on the Windows Scripting Host are probably the most popular to benefit. A great use will be the ease of making C/C++ libraries available in applications supporting the various Basic dialects, such as OpenOffice.org and Microsoft Office. SWIG makes it easy to utilise more advanced C++ code, such as templates, and the COM module is no different here as Jan has added in very comprehensive coverage of the C and C++ languages, full details here: http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-jezabek/Doc/Manual/COM.html

Maciej Drwal has added a module for calling C++ code from C code. It is now possible to automatically create a flattened API of C++ classes so that the C++ functionality is available in the form of easy to use C structs and global functions. For example, features such as C++ template classes / functions are easily callable from C. One cool part of this project is the graceful handling of C++ exceptions in the calling C code. Some introductory documentation is available here: http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-maciekd/Doc/Manual/C.html

Cheryl Foil has added an interesting feature to improve code documentation in the target language. This works when C/C++ code is documented using the industry standard Doxygen tool for annotating methods, classes, variables etc. The new feature extracts the Doxygen comments from the code for use by one of the many target languages. Cheryl has added initial support for Java so that the Doxygen comments are turned into JavaDoc comments embedded into the generated Java wrappers, see http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-cherylfoil/Doc/Manual/Doxygen.html

Lastly, many thanks to the mentors involved in making this happen, Ian Appru, Olly Betts, Richard Boulton and William Fulton and finally to Google for funding a great programme. (0 comments)

 

 

2008/06/24 - SWIG-1.3.36 released
SWIG-1.3.36 has been released. The major changes are listed below.

- Enhancement to directors to wrap all protected members
- Optimisation feature for objects returned by value
- A few bugs fixes in the PHP, Java, Ruby, R, C#, Python, Lua and Perl modules
- Other minor generic bug fixes (0 comments)

 

 

2008/04/21 - Summer of Code students
The students accepted into the Google Summer of Code have now been announced. SWIG has managed to get four slots and we have chosen the following four projects/students:

* "SWIG's Python 3.0 Backend" - Haoyu Bai tutored by Richard Boulton
* "C target language backend" - Maciej Drwal tutored by William Fulton
* "Comment 'Translator' for SWIG" - Cheryl Marie Foil tutored by Olly Betts
* "Support for generating COM wrappers" - Jan Jezabek tutored by Ian Appru

The competition was tough and although it was difficult choosing the projects, these four were our strongest, so congratulations and welcome to Haoyu, Jan, Cheryl and Maciej. Further details on the Google SWIG page - http://code.google.com/soc/2008/swig/about.html . (0 comments)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.