[Xapian-devel] GSoC xapian node binding

Marius Tibeica mtibeica at gmail.com
Fri May 18 09:36:20 BST 2012

On Thu, May 17, 2012 at 6:02 PM, Liam <xapian at networkimprov.net> wrote:

> On Thu, May 17, 2012 at 2:38 AM, Marius Tibeica <mtibeica at gmail.com>wrote:
>> I have tried multiple approaches.
>> The difficulty comes from the fact that each class can have multiple
>> sync/async functions. For example, Enquire has atleast get_mset,
>> get_matching_terms and get_eset.
>> Another problem is that from the pool methods (which should be
>> templatized) I have to call methods from the class (GetMset_process,
>> GetMset_convert, GetMatchingTerm_process, ...). This means that I also
>> probably have to pass a function as a template parameter.
>> The thirt problem is that func##_pool and func##_done need to be (int
>> (eio_req *req)), so I can not pass a function pointer.
>> At the moment I am trying a hybrid approach (bot templates and macroes).
> OK, no need to bend over backwards. Simplicity is preferable after all.

I tend to agree. The hybrid approach is even more complicated.

template <class dataType, class className>
class PoolHelper
  template <Handle<Value> (*convertFunction)(className *data)>;
  static void execute_done(eio_req *data)
    HandleScope scope;
    OpInfo* aInfo = (OpInfo*) req->data;
    dataType *aData = (dataType*)aInfo->data;
    AsyncOp<className> *aAsOp = (AsyncOp<className>*)aInfo->op;
    Handle<Value> argv[2];
    if (aAsOp->error) {
      argv[0] =
    } else {
      argv[0] = Null();
      argv[1] = convertFunction(aData);
    tryCallCatch(aAsOp->callback, aAsOp->object->handle_, aAsOp->error ? 1
: 2, argv);
    delete aData;
    delete aAsOp;
    delete aInfo;

#define DECLARE_POOLS(func,classn) \
static int func##_done(eio_req *req) {\
  HandleScope scope;\
  return 0;\

I will leave the macro as it is.

The question now is, what's next?
Should I start implementing other methods?

> _______________________________________________
> Xapian-devel mailing list
> Xapian-devel at lists.xapian.org
> http://lists.xapian.org/mailman/listinfo/xapian-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xapian.org/pipermail/xapian-devel/attachments/20120518/c6fe0ab4/attachment.htm>

More information about the Xapian-devel mailing list