Thrift: OCaml library and generator
Summary: Added (minimal) library and code generator for OCaml.
Reviewed by: mcslee
Test plan: Test client and server (included).
Revert plan: yes
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665163 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/ocaml/src/TServer.ml b/lib/ocaml/src/TServer.ml
new file mode 100644
index 0000000..d8509ff
--- /dev/null
+++ b/lib/ocaml/src/TServer.ml
@@ -0,0 +1,30 @@
+open Thrift
+
+class virtual t
+ (pf : Processor.factory)
+ (st : Transport.server_t)
+ (itf : Transport.factory)
+ (otf : Transport.factory)
+ (ipf : Protocol.factory)
+ (opf : Protocol.factory)=
+object
+ val processorFactory = pf
+ val serverTransport = st
+ val inputTransportFactory = itf
+ val outputTransportFactory = otf
+ val inputProtocolFactory = ipf
+ val outputProtocolFactory = opf
+ method virtual serve : unit
+end;;
+
+
+let run_basic_server proc port =
+ Unix.establish_server (fun inp -> fun out ->
+ let trans = new TChannelTransport.t (inp,out) in
+ let proto = new TBinaryProtocol.t (trans :> Transport.t) in
+ try
+ while proc#process proto proto do () done;
+ ()
+ with e -> ()) (Unix.ADDR_INET (Unix.inet_addr_of_string "127.0.0.1",port))
+
+