Instructions for hacking on Xapian's bindings
=============================================

This file is aimed to help developers get started with working on
Xapian's bindings.  You should also read the HACKING file in the
xapian-core sources which gives information which isn't specific
to the bindings.

Extra options to give to configure:
===================================

Note: Non-developer configure options are described in INSTALL

--enable-maintainer-mode
	This tells configure to enable make dependencies for regenerating build
	system files (such as configure, Makefile.in, and Makefile), and also
	enables rules to rebuild the bindings glue code by rerunning SWIG.
	You'll need to specify this if you're going to modify configure.ac, any
	Makefile.am, or any .i file.

Packages to install for each language
=====================================

C#
--

Debian wheezy::

apt-get install mono-devel

Java
----

Debian wheezy::

apt-get install openjdk-6-jdk

Lua
---

Debian wheezy::

apt-get install lua5.2 liblua5.2-dev

Perl
----

Debian wheezy: all required are packages installed by default.

PHP5
----

Debian wheezy::

apt-get install php5-dev php5-cli

PHP7
----

Debian stretch::

apt-get install php7.0-cli php7.0-dev

Python
------

Debian wheezy::

apt-get install python-dev

Ruby
----

Debian wheezy::

apt-get install ruby-dev

Tcl
---

Debian wheezy::

apt-get install tcl-dev

Adding support for other programming languages
==============================================

Many languages can be done using SWIG, and it's probably easier to do so
even though some languages may have better tools available just because it's
less overall work.  SWIG makes it particularly easy to wrap a new method for
all the supported languages at once, often by just copying the new method
prototype into xapian.i (and for some headers we parse the Xapian header
directly so no work is needed!)

What's really needed is someone interested in bindings for a particular
language who knows that language well and will be using them actively.
We can help with the Xapian and SWIG side, but without somebody who knows
the language well it's hard to produce a solid, well tested set of bindings
rather than just a token implementation...

To be worth shipping in the xapian-bindings tarball, bindings for an additional
language really need a version of the smoketest (so we can be confident that
they actually work!), and also documentation and examples along the lines of
the existing bindings (without these the bindings aren't likely to be useful to
anyone else).

To give an idea of how much work a set of bindings might be, the author of the
Ruby bindings estimated they took about 25 hours, starting from not knowing
SWIG.  However, the time taken could vary substantially depending on the
language, how well you know it, and how well SWIG supports it.

XS bindings for Perl have been contributed for Perl, and these are available
on CPAN as `Search::Xapian`.  We also have SWIG-based Perl bindings which are
in the ``perl`` subdirectory here, as a `Xapian` module.  These are replacing
the XS-based `Search::Xapian`, and will eventually be on CPAN (certainly once
1.4.0 is out, and probably before).  Currently SWIG's Perl backend doesn't
support directors, so doesn't give us an easy mechanism for callbacks (e.g. for
Xapian::MatchDecider) but perhaps we can do these by hand as they are in the XS
bindings.

These are languages which SWIG supports and which people have done some work
on producing Xapian bindings for:

Pike		Bill Welliver has written some Pike bindings for Xapian
		covering some of the API, which are available from here:
		http://modules.gotpike.org/module_info.html?module_id=42
		These bindings appear to be hand-coded rather than generated
		using SWIG.

Guile		rm@fabula.de did some work on getting Guile bindings working,
		but sadly most of this was lost when his laptop's hard disk
		died.

There are a number of other languages which SWIG supports, but which nobody has
yet (to our knowledge!) worked on producing Xapian bindings for - see
http://www.swig.org/compare.html for a list of supported languages.

It may be possible to support a language which isn't listed above, but it's
likely to be harder unless you're already familiar with the tools available
for wrapping a C++ library for use with that language.

Implementing Deprecation Warnings for the Bindings
=================================================

Currently we don't have an equivalent of the C++ ``XAPIAN_DEPRECATED()`` macro
for the bindings, but it would be good to have.  Here are some notes on how
this could be achieved for various languages we support:

  * PHP 5.3 added an E_USER_DEPRECATED error level, and we now require at
    least 5.5.

    And then in a deprecated method we do:

      trigger_error('World::hi() is deprecated, use World::hello() instead', XAPIAN_DEPRECATED);

  * Python has DeprecationWarning, which we were using in 1.2.x a bit::

      warnings.warn('World::hi() is deprecated, use World::hello() instead', DeprecationWarning)

  * Ruby - there are external libraries to handle deprecation warnings, but the
    simplest option without external dependencies seems to be::

      warn '[DEPRECATION] 'World::hi() is deprecated, use World::hello() instead')

  * Perl::

     use warnings;
     warnings::warnif('deprecated', 'World::hi() is deprecated, use World::hello() instead');

  * Java has @Deprecated, but I think that's a documentation thing only.

It would be great (but probably hard) to reuse the XAPIAN_DEPRECATION()
markers.  Perhaps parsing the doxygen XML for @deprecated markers would be
simpler?

Also, it would be good if the warnings could be turned off easily, as runtime
deprecation warnings can be annoying for end users.
