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/TSimpleServer.ml b/lib/ocaml/src/TSimpleServer.ml
new file mode 100644
index 0000000..1a85809
--- /dev/null
+++ b/lib/ocaml/src/TSimpleServer.ml
@@ -0,0 +1,24 @@
+open Thrift
+module S = TServer
+
+class t pf st itf otf ipf opf =
+object
+ inherit S.t pf st itf otf ipf opf
+ method serve =
+ try
+ st#listen;
+ let c = st#accept in
+ let proc = pf#getProcessor c in
+ let itrans = itf#getTransport c in
+ let otrans = try
+ otf#getTransport c
+ with e -> itrans#close; raise e
+ in
+ let inp = ipf#getProtocol itrans in
+ let op = opf#getProtocol otrans in
+ try
+ while (proc#process inp op) do () done;
+ itrans#close; otrans#close
+ with e -> itrans#close; otrans#close; raise e
+ with _ -> ()
+end