From: Olly B. <ol...@su...> - 2011-05-30 03:51:25
|
I've been working on getting the PHP director support to work for Xapian, and the only missing piece now seems to be that objects passed to PHP methods from C++ are currently passed as a raw resource, without the usual PHP class wrapper. Passing non-class types like integers, strings, etc seems to work correctly. I've managed to work out the PHP API calls needed to sort this out - here is an example fixed by hand where a XapianDocument object is passed: http://trac.xapian.org/attachment/ticket/488/php-generated-code-director-fix.patch I've nearly got this slotted into an updated directorin typemap - the only part I still need is to get the string "xapiandocument" substituted. I think the best way to achieve that is to add a new PHP-specific typemap special variable. The "Typemaps" chapter suggests such variables exist: This is by no means a complete list as some target languages have additional special variables which are documented in the language specific chapters. However, I've failed to work out how and where to set these. What I want is the prefix (which is just in a variable in php.cxx, and "Xapian" in my case), with sym:name for the class being passed (which is "Document" in the hand converted example) appended, all forced to lowercase. Any hints? Cheers, Olly |
From: Olly B. <ol...@su...> - 2011-05-30 05:03:08
|
Olly Betts writes: > I've managed to work out the PHP API calls needed to sort this out - > here is an example fixed by hand where a XapianDocument object is passed: > > http://trac.xapian.org/attachment/ticket/488/php-generated-code-director- fix.patch > > I've nearly got this slotted into an updated directorin typemap - the only > part I still need is to get the string "xapiandocument" substituted. Looking at this further, I've discovered that actually this should already work, except that the optional prefix (as set by the SWIG/PHP backend specific -prefix command line option) isn't taken into account. The code to do the wrapping tries to create a "Document" PHP class wrapper, but there's no PHP class called "Document" (it's "XapianDocument"). So I don't think a new typemap special variable will help, but I can see a way to sort this out. Cheers, Olly |