12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970(*
* Trap: connecting items to stream locations.
* Copyright (C) 2008
* Dmitri Boulytchev, St.Petersburg State University
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2, as published by the Free Software Foundation.
*
* This software 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 Library General Public License version 2 for more details
* (enclosed in the file COPYING).
*)moduletypeSig=sigtypetvalattach:t->Msg.Locator.t->unitvallocate:t->Msg.Locator.tvalcopier:t->t->unitvalcleanup:unit->unitendmoduletypeTrapped=sigtypetvalhash:t->intendmoduleDefault(X:sigtypetend)=structincludeXlethash=Hashtbl.hashendmoduleMake(X:Trapped)=structtypet=X.tmoduleXHash=Hashtbl.Make(structincludeXletequal=(==)end)lettrapTab=(XHash.create1024:Msg.Locator.tXHash.t)letcleanup()=XHash.cleartrapTabletattachstrloc=XHash.addtrapTabstrlocletlocatestr=tryXHash.findtrapTabstrwithNot_found->Msg.Locator.Noletcopierx=letloc=locatexin(funy->attachyloc)endmoduleString=Make(Default(structtypet=stringend))