[Xapian-devel] GSoC xapian node binding

Liam xapian at networkimprov.net
Wed May 16 06:55:54 BST 2012

On Sat, May 12, 2012 at 1:00 AM, Marius Tibeica <mtibeica at gmail.com> wrote:

> I have designed a way to provide both sync and async variants from the
> same code for a nodejs binding.
> The code can be found at:
> https://github.com/mtibeica/node-xapian/blob/master/xapian-op.h
> https://github.com/mtibeica/node-xapian/blob/master/xapian-enquire.h
> https://github.com/mtibeica/node-xapian/blob/master/xapian-enquire.cc
> Every method which has both sync and async has to have the following C++
> methods (GetMset as an example):
> struct GetMset_data { ... }
> -  the data which will be passed
> static Handle<Value> GetMset(const Arguments& args);
> -  parse the sync method parameters and create the GetMset_data object.
> static Handle<Value> GetMsetSync(const Arguments& args);
> - parse the async method parameters and create the GetMset_data object.
> static Xapian::Error* GetMset_process(GetMset_data *data, Enquire *pThis);
> - the actual data processing (which will happen either on the thread pool
> or on the main thread depending on the called method).
> static Handle<Value> GetMset_convert(GetMset_data *data);
> - converts the GetMset_data into a JS object which will be either returned
> or sent as a parameter in a callback
> DECLARE_POOLS(GetMset,Enquire)
> - macro which creates other helping methods
> Another advantage is that the libeio code is isolated in xapian-op.h, so
> porting to node 0.6+ will be easier.
> Any suggestions?

Calling the files xapian-* makes me wonder if they're from the xapian
codebase, so I think we can omit that filename prefix.

In the DECLARE_POOLS macro and Enquire class, you'll merge the sync & async
variants as we discussed?

Those methods both have a try block, but I think only the AsyncOp ctor can
throw? If so, the try block should contain just that call.

In my code GetMset_data is derived from an AsyncOp<Enquire>. Your code
packages those two via the new OpInfo class. Why the change?

Did you consider how those macro functions could be templatized?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xapian.org/pipermail/xapian-devel/attachments/20120515/3a8c0c96/attachment-0001.htm>

More information about the Xapian-devel mailing list