123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354(*
* BatMarshal - Extended marshaling operations
* Copyright (C) 1997 Xavier Leroy
* 2008 David Teller
*
* 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,
* with the special exception on linking described in file LICENSE.
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)includeMarshal##V<4.2##letfrom_bytes=from_string##V<4.2##externalto_bytes:##V<4.2##'a->extern_flagslist->Bytes.t="caml_output_value_to_string"letoutputout?(sharing=true)?(closures=false)v=letflags=matchsharing,closureswith|true,false->[]|true,true->[Closures]|false,false->[No_sharing]|false,true->[No_sharing;Closures]inletbuf=to_string vflagsinBatInnerIO.nwriteoutbufletinputinp=letheader=Bytes.createheader_sizeinletread=BatInnerIO.really_inputinpheader0header_sizeinassert(read=header_size);let data_size=data_sizeheader0inletbuf=Bytes.extendheader0data_sizeinletread=BatInnerIO.really_inputinpbufheader_size data_sizeinassert(read=data_size);from_bytesbuf0letfrom_channel=inputletto_channel outvflags =BatInnerIO.nwriteout(to_stringvflags)