Greetings,
Hi Kent,
Thanks for the offer. Some questions follow.
The HLL discussion pages points to a PPT presentation on swig, mentioning
that the swig interface file could be distributed:
1) Are these swig interface files available?
2) How do they compare to permafrost's swig interface files, see
http://code.google.com/p/permafrost.
3) Anyother known sources of hdf5 swig interface files? Any considered to
be the reference interface definition?
I wrote the Swig interface referred to here and then abandoned it after the
h5py package became available. My interface was very rudimentary and rather
specific to Python. I was trying to do a minimal amount of work and let the
SWIG do most of the work.
A number of problems cropped up during its development.
1) The use of macros in the C API of HDF5 causes problems because SWIG
cannot automatically analyze them. (I would like to see them removed though
I can't see how this can be done without an API change.) I got around this
by cheating, but the right way to to do is to write code to wrap the macros
by hand.
2) Later versions SWIG became rather strict about not allowing python to
convert integers to pointers. The numpy module for Python can provide a
pointer to array memory as a Python integer. The HDF5 C API wants void *,
etc. and the Python SWIG wrapper reflects this. I started a C conversion
library which was nothing more than functions of integers which cast the
argument into a a pointer, eg:
void *Return_void (int NumPyInt) {
return (void *) NumPyInt;
}
When wrapped by SWIG this provided the necessary type conversion functions
in Python. The opaque object returned to the Python interpreter could be
passed to the SWIG interface to HDF5.
If you want to develop a Ruby interface I would recommend starting by
looking at Andrew Collette's excellent h5py interface. It was written using
a Python specific C interface so the code itself probably isn't useful to
Ruby, but it will give you a sense of the effort involved. If you are
familiar with Python you'll also see the nice way in which h5py "shoe horns"
the API and HDF5 objects into the syntactic structures familiar to Python
programmers. I imagine there are similar opportunities in developing the
Ruby interface.
Thanks for the feedback. I will look at h5py more closely.
After wrestling with Permafrost's swig interface files (Java centric)
I discovered that it is possible to get a lot of tedious lifting done
with ruby's ffi-swig library and a minimal interface file passed to
swig. Specifically:
# ------------------ start ------------------------
%module Hdf5
%{
require 'rubygems'
require 'ffi'
module Hdf5::Mixin
extend FFI::Library
%}
#include hdf5.h
%{
end
%}
# ------------------ end ------------------------
I generate a xml file with swig as follows:
swig -includeall -Wall -Wallkw
- -I/usr/lib/gcc/i586-suse-linux/4.3/include -I/usr/include
- -I/usr/src/hdf5-1.8.3/src -ruby -xmlout
~/hdf/ruby/hdf/ext/interfaces/hdf5.xml hdf5.i
This is then passed to Ruby's ffi-gen utility and a large part of the
tedious work is done. I just did this last night so how much hand
editing will be required remains to be seen.
Anyway it seems that the xml representation of the swig results is
what helps ffi-swig-generate - that pathway may be of interest to
some.
Best wishes
HH
Cheers,
--dan
--
Daniel Kahn
Science Systems and Applications Inc.
301-867-2162
- --
πόλλ' οἶδ ἀλώπηξ, ἀλλ' ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://wiki.hedgehogshiatus.com
···
On Sat, Jun 27, 2009 at 7:34 AM, Daniel Kahn wrote:
hedgehogshiatus@gmail.com wrote:
----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.