Robert Roessler wrote:
Robert Roessler wrote:
...
While I am of course attempting to use some of the existing FFI code as
examples of how to do this (the "trees"), I don't fully grasp the
underlying idea(s) (the "forest")... and so am adding various
definitions of "set_finalize" into a number of extra/CInterface/*.ML
files - with "mixed results". :|

Could you outline the *minimum* changes to SML structures and signatures
to connect a

CInterface set_finalize vol -> sym -> unit

function to (I think)

static Handle set_finalize (TaskData *taskData, Handle h)

in foreign.cpp (assuming it will go in at the end of the "handlers"
array)?

If it's helpful, I can be more specific about what I have tried... while
I still really want to know how in general to add primitives to Poly
(and *why* it is done that way), if it is easier for you to point out
where I am going wrong, here is where our story so far:

CInterfaceSig (after val mapSym...)
val set_finalize : vol -> sym -> unit

LowerLevelSig (after val mapSym...)
val set_finalize : vol -> sym -> unit

LowerLevel (after fun get_sym...
fun set_finalize vol sym =
Volatile.set_finalize vol sym; (* Use Volatile. or not? *)

OK, this is now just

fun set_finalize vol sym =
    set_finalize vol sym

DispatchSig (after val toPascalfunction...)
val set_finalize : rawvol -> rawvol -> unit

Dispatch (after val toPascalfunction...)
val set_finalize = next(two);

VolatileSig (after val toPascalfunction...)
val set_finalize : vol -> vol -> unit

VOLS_THAT_HOLD_REFS (after fun toPascalfunction...)

OK, this is now

fun set_finalize vol sym =
    Underlying.set_finalize (#thevol vol) (#thevol sym)

???

Progress, of sorts - this builds (including the ML-land bootstrapping) - and I can do all the DLL loading, sym grabbing, and creation of C++ vols using one of my DLL entry points. Finally, I can even manually invoke the "finalizer" on this vol, and the proper delete is done, including all of the virtual destructors.

BUT, if I try to do an actual set_finalize to set the new field in the Volatile structure, Poly just goes into a (interruptable) hard loop - without hitting my breakpoint in foreign.cpp:set_finalize(...).

Robert
_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to