[Nexus] Problems with NXgetnextentry

Simmonds Paul simmonds at ill.fr
Wed May 28 12:54:30 BST 2003


Mark Koennecke wrote:
<snipped>

>   - We are currently working on a general interface between the NeXus-API
>     and scripting languages using SWIG (http://www.swig.org). This SWIG
>     interface is already known to work for Tcl and mzScheme. I would like
>     to ask you to download the most recent version of the NAPI from the
>     CVS repository and to donate you experience with python to get this
>     SWIG interface to work with python. If the promise of SWIG holds
>     this might give you a working Python NeXus API in half a  day.

Thanks Mark,
I have already had a look at SWIG, and it does interface with Python very
well. However, it provides a very transparent layer: the Python objects
are fine, but the attributes to those objects are C objects, and so are
untreatable in a Python context. C functions also take a precise number
of arguments, so optional or default arguments are not possible if only
the thin layer SWIG provides is used.

What I'm aiming for is something more malleable, allowing the user to
create and manipulate NeXus files from the Python interpreter interactive
prompt. This then would act almost like a text-based browser, complete
with support for Python's help and documentation, which SWIG does not
support (yet?). It would then be a relatively simple matter to create a
GUI browser using one of the GUI interfaces.

>     Moreover, some important bug fixes have recently been made to the
>     version of NAPI in the  CVS repository, perhaps you would like to
>     benefit of those as well. If you wish to follow this road either
>     Freddy Akeroyd (Freddy.Akeroyd at rl.ac.uk) or I can give you the
>     details how to access the NAPI CVS repository. Or give you a dump
>     of it if you are not familiar with CVS.

At the moment I haven't been having any problems with the API itself-
most of the problems I've been having can be put down to programmer
error. Like this one.
<snip>

>     No space is allocated for name and class. NXgetnextentry
>     now copies data to pointers pointing to nowhere. Your program is in
>     trouble memory wise then and anything could happen. I suggest to
>     change:
>         char *name, *class;
>     to:
>         NXname name, class;
>     and to try again. NXname is a typedef to char[128], see napi.h

That's just what I was looking for. I didn't want to create my own
arbitrary maximum lengths, and didn't find NXname. Thanks for pointing
that out, especially as it seems some of my code was working by accident.

In the hierarchy, though I find a group named with what was (I assume)
the original filename, with a class of "CDF0.0". In each of the files I
have tried, I found a few levels under that a group of class "UNKNOWN".
The API doesn't know how to open this, so an error is returned. I haven't
found a reference to these class types anywhere.

Thanks,
Paul

>                         I hope this helps,
>
>                                 Mark Koennecke





More information about the NeXus mailing list