[Xapian-discuss] Writing a MatchDecider and exposing it to PHP

Olly Betts olly at survex.com
Fri Mar 23 01:45:22 GMT 2012


On Tue, Mar 20, 2012 at 11:16:42AM +0000, Paul Dixon wrote:
> I would like to write a MatchDecider in C++ and expose it to PHP.
> 
> I'm able to compile a simple extension and use SWIG to expose a simple
> function to PHP, but I can't seem to hit upon the right incantation to
> expose my MatchDecider class.

I've not tried it myself, but I believe SWIG does support wrapping
an extension which builds on another extension like this.

> 	#include <xapian/enquire.h>
> 	#include <xapian/types.h>

Just include <xapian.h> in user code - the other headers are an
implementation detail and might get renamed, merged, split, etc.

On Tue, Mar 20, 2012 at 12:02:44PM +0000, Paul Dixon wrote:
> Just to follow up on earlier message - I was able to get somewhere
> with this as my interface file
[...] 
> %include "mydecider.h"

Yes, SWIG doesn't parse included files by default, and the %include
tells it to.

> This created a 'proxy' PHP class, but isn't there some way to make my
> class a 'real' PHP class?

I'm not sure I understand what you mean.  You are wanting a class which
wraps a C++ class, which is what a 'proxy' class is - a PHP class which
forwards its methods to a C++ class, 

Cheers,
    Olly



More information about the Xapian-discuss mailing list