[ooc-compiler] Interfacing OOC to Gnu Scientific Library
Brought to you by:
mva
|
From: Stewart G. <sgr...@ip...> - 2002-02-04 08:56:25
|
Hi Folks, I'm interested in using GSL (Gnu Scientific Library) with OOC. The GSL is available under GPL, and works under ANSI C. For details, see: http://sources.redhat.com/gsl/ I've done an initial brute-force auto-translation of the GSL interface, available here: http://espc22.murdoch.edu.au/~stewart/files/gsl1.0-oo2c.tar.gz To try it, extract the files and in the gsl directory do: oo2c -Mv Example1 ./Example1 It should print out the value of J_0(1.0). There appear to be two issues with OOC. 1) GSL includes support for "long double" types. In my translation, I've employed: float -> REAL double -> LONGREAL long double -> HUGEREAL To make it compile, I did this: TYPE HUGEREAL = LONGREAL; which is almost certainly wrong and will break all these functions in horrible ways. I suspect that it would probably be too much work to support this type under OOC, so its probably best to just remove all of the affected functions and types. 2) GSL makes quite frequent use of C's ability to pass / return structures by value. I did a rough calculation and it appears that of 3500 functions, approximately 500 are affected in this way. This includes all complex math functions, some BLAS functions (eg. passing complex constants by value), and various fuctions related to the use of views of vectors and matrices. In the translated interface the affected functions are annotated "Function returns RECORD", or "Function has RECORD parameter" (or both) so searching for "Function" will show you which ones are involved. It would be useful to be able to pass C records by value to and from C functions. I suspect that this is probably not too hard to acheive, although I have not looked at the details. Michael, how easy is this to do? I'm not suggesting that the feature be used within Oberon-2, just as a way of interfacing to C. It would only need to work with records declared in interface modules. If anyone else is interested in this, let me know. It might encourage me to persevere with this. Cheers, Stewart |