Ticket #416: util.i.patch

File util.i.patch, 738 bytes (added by Donny, 15 years ago)

Patch file for util.i

  • util.i

    old new  
    2626#endif
    2727
    2828#include "../xapian-version.h"
     29
    2930%}
    3031
    3132/* Add a section to the output from phpinfo(). */
     
    140141    }
    141142}
    142143
     144#define XAPIAN_STRING_DOCCOUNT_MAP_OUTPUT_TYPEMAP
     145%typemap(out) const std::map<std::string, Xapian::doccount> & {
     146  if (array_init($result) == FAILURE) {
     147          SWIG_PHP_Error(E_ERROR, "array_init failed");
     148  }
     149  for (std::map<std::string, Xapian::doccount>::iterator i = $1->begin(); i != $1->end(); i++)
     150  {
     151    string term = i->first;
     152    char *p = const_cast<char*>(term.data());
     153    add_assoc_long($result, p, i->second); 
     154  }
     155}
     156
    143157/* vim:set syntax=cpp:set noexpandtab: */