[mercury-users] Calling Mercury from C and handling io__state
Roy Ward
rward at infoscience.otago.ac.nz
Mon Dec 17 21:18:31 AEDT 2001
I'm trying to call a Mercury library from a C module
(the eventual idea is to then use JNI to get at the
Mercury from Java using the C as glue, but first things
first).
The call requires a string, and returns a string. So
far, so good, that part seems easy to set up.
However, the fly gets into the ointment when I realise
that the Mercury code does some file handling (and
also displays things to the screen, but I can do without
that). For this, I need an io_state, and the mode looks
something like this:
:- pred mycall(string::in, string::out, io__state::di, io__state::uo) is
det.
The question is, how do deal with the io__state at the
C end? The only way I know to 'get' an io__state to
work with is to have the Mercury at the top level,
so it goes through mercury_runtime_main(). This
won't work directly for me, because I want the module
to be invoked from elsewhere. I need to have something
to pass to mycall when I call it.
Any suggestions or example code on how to do this?
Cheers,
Roy Ward.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list