blob: 9f871fbd93e28ec666cfaf281dbbed7b9670b311 [file] [log] [blame]
iproctor9a41a0c2007-07-16 21:59:24 +00001Library
2-------
3The library abstract classes, exceptions, and general use functions are mostly jammed in Thrift.ml (an exception being TServer). Implementations live in their own files. I'm on the fence about whether it should be done with objects or modules/functors. Right now they are objects. TBinaryProtocol and TSocket are implemented. TServer and TSimpleServer classes are there, but the fastest route to a binary protocol socket server is to use TServer.run_basic_server which uses OCaml's own server abstraction. To that end, there is TChannelTransport which is a transport class parametrized on input and output channels that does nothing but wrap up the input and output functions.
4
5A note on making the library: Running make should create native and bytecode libraries.
6
7
8Struct format
9-------------
10Structs are turned into classes. The fields are all option types and are initially None. Write is a method, but reading is done by a separate function (since there is no such thing as a static class). I'm still arguing with myself about whether structs should be put in their own modules along with this read function.
11
12
13enum format
14-----------
15Enums are put in their own module along with functions to_i and of_i which convert the ocaml types into ints. For example:
16
17enum Numberz
18{
19 ONE = 1,
20 TWO,
21 THREE,
22 FIVE = 5,
23 SIX,
24 EIGHT = 8
25}
26
27==>
28
29module Numbers =
30struct
31type t =
32| ONE
33| TWO
34| THREE
35| FIVE
36| SIX
37| EIGHT
38
39let of_i = ...
40let to_i = ...
41end
42
43typedef format
44--------------
45Typedef turns into the type declaration:
46typedef i64 UserId
47
48==>
49
50type userid Int64.t
51
52exception format
53----------------
54Exceptions are kind of ugly since the exception structs can't be thrown directly. They also have this exception type which has the name BLAHBLAH_exn. For example, for an exception Xception you get:
55
56exception Xception_exn of xception
57
58list format
59-----------
60Lists are turned into OCaml native lists
61
62Map/Set formats
63---------------
64These are both turned into Hashtbl.t's.
65
66Services
67--------
68The client is a class "client" parametrized on input and output protocols. The processor is a class parametrized on a handler. A handler is a class inheriting the iface abstract class. Unlike other implementations, client does not implement iface since iface functions must take option arguments so as to deal with the case where a client does not send all the arguments.