1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
(*
Copyright (c) 2000
Cambridge University Technical Services Limited
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*)
functor VOL_BASIC
(structure Ctype : CtypeSig
structure BehaviourRefs : BehaviourRefsSig
structure Dispatch : DispatchSig
sharing type Dispatch.RawCtype = Ctype.RawCtype
) : VolatileSig =
struct
structure BehaviourRefs = BehaviourRefs;
structure Ctype = Ctype
structure Union = Dispatch.Union;
open Dispatch
type vol = rawvol
open Union
open Ctype
fun offset i ct v = Dispatch.offset v (i * sizeof ct)
fun alloc i ct = Dispatch.alloc (i * sizeof ct)
fun assign ct v w = Dispatch.assign v w (sizeof ct)
fun ID x = x;
fun call_sym_and_convert v args rt =
Dispatch.call_sym_and_convert
v
(map (mapDirectedArg makeRaw ID) args)
(mapUnionChoice makeRaw rt)
(* These both take an ML function and create a vol. They can and should
be applied to the type information before they are applied to the ML
function. It actually doesn't help much because
VOLS_THAT_HOLD_REFS().toCfunction etc sapply them to all the arguments. *)
fun toCfunction argType resType =
Dispatch.toCfunction (map makeRaw argType) (makeRaw resType)
fun toPascalfunction argType resType =
Dispatch.toPascalfunction (map makeRaw argType) (makeRaw resType)
end;
|