[Xapian-devel] GSoC xapian node binding

Marius Tibeica mtibeica at gmail.com
Wed May 16 11:30:48 BST 2012

On Wed, May 16, 2012 at 8:55 AM, Liam <xapian at networkimprov.net> wrote:

> 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.
Sure. And maybe move them to a src folder

> In the DECLARE_POOLS macro and Enquire class, you'll merge the sync &
> async variants as we discussed?
Yes. And later we will create a js wrapper to avoid confusion.

> 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?
Because the sync version only requires the GetMset_data (and id does not
need the AsyncOp initialization). This way i can have the same GetMset_data
structure for both methods.

> Did you consider how those macro functions could be templatized?
Will do.

> Liam
> _______________________________________________
> 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/20120516/ac586d8b/attachment-0001.htm>

More information about the Xapian-devel mailing list