The host language is Haskell; so far I've managed to wrap Petsc structures made up of elementary types and with no macros inside (e.g. _n_PetscLayout ), and Petsc functions that operate on typedefs of elementary types (e.g. PetscInitialize() ). _p_Vec and similar are proving harder to implement. (Haskell requires one to write instances of a certain typeclass Storable, that add pointer-like functionality to the instanced datatypes) On the other hand, I cannot treat Vec, Mat etc. simply as a opaque pointers because Petsc uses them both by value and by reference.
On 14 May 2015 at 22:26, Jed Brown <[email protected]> wrote: > Marco Zocca <[email protected]> writes: > >> Dear all, >> >> I am trying to write a petsc foreign-function wrapper for a different >> language. >> What I don't understand at the moment is the role of macros in setting >> up structs. For example, in the implementation of Vec summarised >> below, when and how is PETSCHEADER expanded? > > It's expanded by the C Preprocessor. But why are you looking at this? > Those are private headers not even available to C callers. Why do you > feel compelled to access these from a different language?
